Bladeren bron

[Pretty errors] Position file is already resolved, don't resolve again (#11700)

* Pretty errors: pfile is already resolved

* [tests] add test

* Simplify test hxml
Rudy Ges 1 jaar geleden
bovenliggende
commit
5e58a479c1

+ 1 - 12
src/compiler/messageReporting.ml

@@ -56,15 +56,6 @@ let resolve_source file l1 p1 l2 p2 =
 		List.rev !lines
 		List.rev !lines
 	end
 	end
 
 
-let resolve_file ctx f =
-	let ext = StringHelper.extension f in
-	let second_ext = StringHelper.extension (StringHelper.remove_extension f) in
-	let platform_ext = "." ^ (platform_name_macro ctx) in
-	if platform_ext = second_ext then
-		(StringHelper.remove_extension (StringHelper.remove_extension f)) ^ ext
-	else
-		f
-
 let error_printer file line = Printf.sprintf "%s:%d:" file line
 let error_printer file line = Printf.sprintf "%s:%d:" file line
 
 
 type error_context = {
 type error_context = {
@@ -98,10 +89,8 @@ let compiler_pretty_message_string com ectx cm =
 				let epos = if is_unknown_file cm.cm_pos.pfile then "(unknown position)" else cm.cm_pos.pfile in
 				let epos = if is_unknown_file cm.cm_pos.pfile then "(unknown position)" else cm.cm_pos.pfile in
 				(-1, -1, -1, -1, epos, [])
 				(-1, -1, -1, -1, epos, [])
 			end else try begin
 			end else try begin
-				let f = resolve_file com cm.cm_pos.pfile in
-				let f = Common.find_file com f in
 				let l1, p1, l2, p2 = Lexer.get_pos_coords cm.cm_pos in
 				let l1, p1, l2, p2 = Lexer.get_pos_coords cm.cm_pos in
-				let lines = resolve_source f l1 p1 l2 p2 in
+				let lines = resolve_source cm.cm_pos.pfile l1 p1 l2 p2 in
 				let epos =
 				let epos =
 					if lines = [] then cm.cm_pos.pfile
 					if lines = [] then cm.cm_pos.pfile
 					else if ectx.absolute_positions then TPrinting.Printer.s_pos cm.cm_pos
 					else if ectx.absolute_positions then TPrinting.Printer.s_pos cm.cm_pos

+ 1 - 0
tests/misc/projects/Issue11700/.haxelib/mylib/.current

@@ -0,0 +1 @@
+git

+ 1 - 0
tests/misc/projects/Issue11700/.haxelib/mylib/git/src/Main.hx

@@ -0,0 +1 @@
+Nope

+ 5 - 0
tests/misc/projects/Issue11700/compile-fail.hxml

@@ -0,0 +1,5 @@
+-lib mylib
+-cp src
+-main Main
+-D message.reporting=pretty
+-D message.no-color

+ 6 - 0
tests/misc/projects/Issue11700/compile-fail.hxml.stderr

@@ -0,0 +1,6 @@
+[ERROR] src/Main.hx:1: characters 1-6
+
+ 1 | trace("");
+   | ^^^^^
+   | Unexpected trace
+

+ 1 - 0
tests/misc/projects/Issue11700/src/Main.hx

@@ -0,0 +1 @@
+trace("");