[vala/wip/issue/1261] vala: Report statement parsing error if it is not meant to be an expression




commit f5934184d050d1a19f394fdab6f2ee66ff30965f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Dec 13 12:38:01 2021 +0100

    vala: Report statement parsing error if it is not meant to be an expression
    
    Fixes https://gitlab.gnome.org/GNOME/vala/issues/1261

 vala/valaparser.vala | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 76c2bc92e..d61a581e0 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -1686,8 +1686,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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]