|
@@ -113,6 +113,12 @@ let semicolon s =
|
|
|
| [< s >] ->
|
|
|
syntax_error Missing_semicolon s (next_pos s)
|
|
|
|
|
|
+let check_redundant_var p1 = parser
|
|
|
+ | [< '(Kwd Var),p2; s >] ->
|
|
|
+ syntax_error (Custom "`final var` is not supported, use `final` instead") ~pos:(Some (punion p1 p2)) s ();
|
|
|
+ | [< >] ->
|
|
|
+ ()
|
|
|
+
|
|
|
let parsing_macro_cond = ref false
|
|
|
|
|
|
let rec parse_file s =
|
|
@@ -955,9 +961,8 @@ and parse_class_field tdecl s =
|
|
|
name,punion p1 p2,FVar (t,e),al,meta
|
|
|
end
|
|
|
| [< '(Kwd Final,p1) >] ->
|
|
|
+ check_redundant_var p1 s;
|
|
|
begin match s with parser
|
|
|
- | [< '(Kwd Var),p2 >] ->
|
|
|
- error (Custom "`final var` is not supported, use `final` instead") (punion p1 p2)
|
|
|
| [< opt,name = questionable_dollar_ident; t = popt parse_type_hint; e,p2 = parse_var_field_assignment >] ->
|
|
|
let meta = check_optional opt name in
|
|
|
name,punion p1 p2,FVar(t,e),(al @ [AFinal,p1]),meta
|
|
@@ -1140,9 +1145,8 @@ and parse_block_var = parser
|
|
|
| [< '(Kwd Var,p1); vl = parse_var_decls false p1; p2 = semicolon >] ->
|
|
|
(vl,punion p1 p2)
|
|
|
| [< '(Kwd Final,p1); s >] ->
|
|
|
+ check_redundant_var p1 s;
|
|
|
match s with parser
|
|
|
- | [< '(Kwd Var),p2 >] ->
|
|
|
- error (Custom "`final var` is not supported, use `final` instead") (punion p1 p2)
|
|
|
| [< vl = parse_var_decls true p1; p2 = semicolon >] ->
|
|
|
(vl,punion p1 p2)
|
|
|
| [< >] ->
|
|
@@ -1278,9 +1282,8 @@ and parse_macro_expr p = parser
|
|
|
| [< '(Kwd Var,p1); vl = psep Comma (parse_var_decl false) >] ->
|
|
|
reify_expr (EVars vl,p1) !in_macro
|
|
|
| [< '(Kwd Final,p1); s >] ->
|
|
|
+ check_redundant_var p1 s;
|
|
|
begin match s with parser
|
|
|
- | [< '(Kwd Var),p2 >] ->
|
|
|
- error (Custom "`final var` is not supported, use `final` instead") (punion p1 p2)
|
|
|
| [< vl = psep Comma (parse_var_decl true) >] ->
|
|
|
reify_expr (EVars vl,p1) !in_macro
|
|
|
| [< >] ->
|
|
@@ -1401,9 +1404,8 @@ and expr = parser
|
|
|
end
|
|
|
| [< '(Kwd Var,p1); v = parse_var_decl false >] -> (EVars [v],p1)
|
|
|
| [< '(Kwd Final,p1); s >] ->
|
|
|
+ check_redundant_var p1 s;
|
|
|
begin match s with parser
|
|
|
- | [< '(Kwd Var),p2 >] ->
|
|
|
- error (Custom "`final var` is not supported, use `final` instead") (punion p1 p2)
|
|
|
| [< v = parse_var_decl true >] ->
|
|
|
(EVars [v],p1)
|
|
|
| [< >] ->
|
|
@@ -1632,9 +1634,8 @@ and parse_guard = parser
|
|
|
and expr_or_var = parser
|
|
|
| [< '(Kwd Var,p1); np = dollar_ident; >] -> EVars [mk_evar np],punion p1 (snd np)
|
|
|
| [< '(Kwd Final,p1); s >] ->
|
|
|
+ check_redundant_var p1 s;
|
|
|
begin match s with parser
|
|
|
- | [< '(Kwd Var),p2 >] ->
|
|
|
- error (Custom "`final var` is not supported, use `final` instead") (punion p1 p2)
|
|
|
| [< np = dollar_ident; >] ->
|
|
|
EVars [mk_evar ~final:true np],punion p1 (snd np)
|
|
|
| [< >] ->
|