]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Improve parsing of with-statement and allow it as embedded statement
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 17 Sep 2020 13:16:59 +0000 (15:16 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 17 Sep 2020 13:16:59 +0000 (15:16 +0200)
tests/parser/with-embedded.vala
vala/valaparser.vala

index c668e5afca240a80724acabf563635655ec1eaf2..6f61891d145e887a66c4d4400512b87bfa36ff8d 100644 (file)
@@ -1,4 +1,8 @@
 void main () {
-    with (10)
-        assert (to_string () == "10");
+       if (true)
+               with ("foo")
+                       assert (to_string () == "foo");
+
+       with (10)
+               assert (to_string () == "10");
 }
index d184a8431ffe072cad532217c66f8bde4cdb912e..216cd0a7d235377e9167e0fc2715b22f36af3964 100644 (file)
@@ -1836,6 +1836,7 @@ public class Vala.Parser : CodeVisitor {
                case TokenType.LOCK:      return parse_lock_statement ();
                case TokenType.UNLOCK:    return parse_unlock_statement ();
                case TokenType.DELETE:    return parse_delete_statement ();
+               case TokenType.WITH:      return parse_with_statement ();
                case TokenType.VAR:
                case TokenType.CONST:
                        throw new ParseError.SYNTAX ("embedded statement cannot be declaration ");
@@ -2646,6 +2647,7 @@ public class Vala.Parser : CodeVisitor {
                        case TokenType.UNLOCK:
                        case TokenType.VAR:
                        case TokenType.WHILE:
+                       case TokenType.WITH:
                        case TokenType.YIELD:
                                return RecoveryState.STATEMENT_BEGIN;
                        default: