closes #10358
@@ -1184,6 +1184,7 @@ and parse_var_decl_head final s =
let meta = parse_meta s in
match s with parser
| [< name, p = dollar_ident; t = popt parse_type_hint >] -> (meta,name,final,t,p)
+ | [< >] -> no_keyword "variable name" s
and parse_var_assignment = parser
| [< '(Binop OpAssign,p1); s >] ->
@@ -420,4 +420,9 @@ let check_signature_mark e p1 p2 =
end
let convert_abstract_flags flags =
- ExtList.List.filter_map decl_flag_to_abstract_flag flags
+ ExtList.List.filter_map decl_flag_to_abstract_flag flags
+
+let no_keyword what s =
+ match Stream.peek s with
+ | Some (Kwd kwd,p) -> error (Custom ("Keyword " ^ (s_keyword kwd) ^ " cannot be used as " ^ what)) p
+ | _ -> raise Stream.Failure
@@ -0,0 +1,5 @@
+class Main {
+ static function main() {
+ var final;
+ }
+}
+ var not, final;
+ var final = 0;
@@ -0,0 +1 @@
+--main Main
+Main.hx:3: characters 7-12 : Keyword final cannot be used as variable name
+--main Main2
+Main2.hx:3: characters 12-17 : Keyword final cannot be used as variable name
+--main Main3
+Main3.hx:3: characters 7-12 : Keyword final cannot be used as variable name