Browse Source

detect trailing metadata

closes #11389
Simon Krajewski 5 months ago
parent
commit
57bc78a21e

+ 7 - 1
src/syntax/grammar.ml

@@ -333,7 +333,13 @@ and parse_type_decl ctx mode s =
 					}, punion p1 p2)
 				| [ ] -> check_type_decl_flag_completion ctx mode c s)
 			| _ ->
-				check_type_decl_flag_completion ctx mode c s
+				begin match meta with
+					| (_,_,p) :: _ ->
+						syntax_error ctx ~pos:(Some p) (Custom "Type or field expected after metadata") s ()
+					| [] ->
+						()
+				end;
+				check_type_decl_flag_completion ctx mode c s;
 
 
 and parse_class ctx doc meta cflags need_name s =

+ 2 - 0
tests/misc/projects/Issue11389/Main.hx

@@ -0,0 +1,2 @@
+function main() {}
+@:native("")

+ 2 - 0
tests/misc/projects/Issue11389/compile-fail.hxml

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

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

@@ -0,0 +1 @@
+Main.hx:2: characters 1-9 : Type or field expected after metadata