Browse Source

fix position of "Expected TOKEN" error on Eof
fixes #8527

Aleksandr Kuzmenko 6 years ago
parent
commit
2bf384cbc7

+ 9 - 2
src/syntax/parser.ml

@@ -118,11 +118,11 @@ let last_pos s = pos (last_token s)
 
 let next_token s = match Stream.peek s with
 	| Some (Eof,p) ->
-		(Eof,{p with pmax = max_int})
+		(Eof,p)
 	| Some tk -> tk
 	| None ->
 		let last_pos = pos (last_token s) in
-		(Eof,{last_pos with pmax = max_int})
+		(Eof,last_pos)
 
 let next_pos s = pos (next_token s)
 
@@ -153,6 +153,13 @@ let last_doc : (string * int) option ref = ref None
 let syntax_errors = ref []
 
 let syntax_error error_msg ?(pos=None) s v =
+	(match error_msg with
+	| Expected ["}"] ->
+		print_string "";
+		print_string "";
+		print_string "";
+	| _-> ()
+	);
 	let p = (match pos with Some p -> p | None -> next_pos s) in
 	let p = if p.pmax = max_int then {p with pmax = p.pmin + 1} else p in
 	if not !in_display then error error_msg p;

+ 3 - 0
tests/misc/projects/Issue8527/Main.hx

@@ -0,0 +1,3 @@
+class Main {
+	static function main() {
+}

+ 1 - 0
tests/misc/projects/Issue8527/compile-fail.hxml

@@ -0,0 +1 @@
+-main Main

+ 1 - 0
tests/misc/projects/Issue8527/compile-fail.hxml.stderr

@@ -0,0 +1 @@
+Main.hx:3: character 2 : Expected }