]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
parser: Handle incomplete expression statements 4368a4fa667148378dcdbd251a4ae4e00c9a8e5a
authorPrinceton Ferro <princetonferro@gmail.com>
Thu, 9 Apr 2020 19:15:45 +0000 (21:15 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 11 Apr 2020 14:03:30 +0000 (16:03 +0200)
Incomplete expression statements are parsed as expression statements
now, rather than local variable declarations. This primarily affects
incomplete member access expressions at the end of blocks.

vala/valaparser.vala

index 48818a293b3ff9d6ed9917558313304a60d256f6..e61372975de7dd545a886b05e106cfb53b873c64 100644 (file)
@@ -1665,7 +1665,19 @@ public class Vala.Parser : CodeVisitor {
                var begin = get_location ();
 
                // decide between declaration and expression statement
-               skip_type ();
+               try {
+                       skip_type ();
+               } catch (ParseError e) {
+                       prev ();
+                       var token = current ();
+                       next ();
+                       if (token == TokenType.DOT || token == TokenType.DOUBLE_COLON) {
+                               rollback (begin);
+                               return true;
+                       } else {
+                               throw e;
+                       }
+               }
                switch (current ()) {
                // invocation expression
                case TokenType.OPEN_PARENS: