]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Report statement parsing error if it is not meant to be an expression
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 13 Dec 2021 11:38:01 +0000 (12:38 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 9 Jan 2022 08:59:43 +0000 (09:59 +0100)
Fixes https://gitlab.gnome.org/GNOME/vala/issues/1261

vala/valaparser.vala

index 150678e062cb3275c696efc948123012213b9b7e..c05f4ea669aa2505694694faa24a51734b666a7c 100644 (file)
@@ -1660,8 +1660,12 @@ public class Vala.Parser : CodeVisitor {
                } catch (ParseError e) {
                        var e_begin = get_location ();
                        string token = ((EnumClass) typeof (TokenType).class_ref ()).get_value (type).value_nick;
+                       rollback (begin);
+                       if (!is_expression ()) {
+                               rollback (e_begin);
+                               throw e;
+                       }
                        try {
-                               rollback (begin);
                                stmt = parse_expression_statement ();
                                Report.warning (get_src (begin), "`%s' is a syntax keyword, replace with `@%s'", token, token);
                        } catch (ParseError e2) {