From: Rico Tzschichholz Date: Mon, 13 Dec 2021 11:38:01 +0000 (+0100) Subject: vala: Report statement parsing error if it is not meant to be an expression X-Git-Tag: 0.52.10~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d4416fbd67a44b136a746b8e81e16752ad30c3f;p=thirdparty%2Fvala.git vala: Report statement parsing error if it is not meant to be an expression Fixes https://gitlab.gnome.org/GNOME/vala/issues/1261 --- diff --git a/vala/valaparser.vala b/vala/valaparser.vala index 150678e06..c05f4ea66 100644 --- a/vala/valaparser.vala +++ b/vala/valaparser.vala @@ -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) {