]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Add missing re-check guards for Do/For/WhileStatement and SwitchLabel
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 23 Oct 2018 21:12:06 +0000 (23:12 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Tue, 27 Nov 2018 10:12:16 +0000 (11:12 +0100)
vala/valadostatement.vala
vala/valaforstatement.vala
vala/valaswitchlabel.vala
vala/valawhilestatement.vala

index 987facc908f6b0b198ce8a051d733171a16f8a2e..f34e223584655ff6b196f4ebe8578314680719cd 100644 (file)
@@ -93,6 +93,12 @@ public class Vala.DoStatement : CodeNode, Statement {
        }
 
        public override bool check (CodeContext context) {
+               if (checked) {
+                       return !error;
+               }
+
+               checked = true;
+
                // convert to simple loop
 
                // do not generate variable and if block if condition is always true
@@ -102,7 +108,11 @@ public class Vala.DoStatement : CodeNode, Statement {
                        var parent_block = (Block) parent_node;
                        parent_block.replace_statement (this, loop);
 
-                       return loop.check (context);
+                       if (!loop.check (context)) {
+                               error = true;
+                       }
+
+                       return !error;
                }
 
                var block = new Block (source_reference);
@@ -127,6 +137,10 @@ public class Vala.DoStatement : CodeNode, Statement {
                var parent_block = (Block) parent_node;
                parent_block.replace_statement (this, block);
 
-               return block.check (context);
+               if (!block.check (context)) {
+                       error = true;
+               }
+
+               return !error;
        }
 }
index bd3229ad55ee8490db5421ae83db392a770fae58..aa70cee0bbea159da73e8d7bde134d9bae2ff6af 100644 (file)
@@ -165,6 +165,12 @@ public class Vala.ForStatement : CodeNode, Statement {
        }
 
        public override bool check (CodeContext context) {
+               if (checked) {
+                       return !error;
+               }
+
+               checked = true;
+
                // convert to simple loop
 
                var block = new Block (source_reference);
@@ -206,6 +212,10 @@ public class Vala.ForStatement : CodeNode, Statement {
                var parent_block = (Block) parent_node;
                parent_block.replace_statement (this, block);
 
-               return block.check (context);
+               if (!block.check (context)) {
+                       error = true;
+               }
+
+               return !error;
        }
 }
index d3df5a3ee7182b2ffa13fc36e5954566ec34584d..ca92de04ca8d30f47930e769d505918063fb5985 100644 (file)
@@ -78,6 +78,12 @@ public class Vala.SwitchLabel : CodeNode {
        }
 
        public override bool check (CodeContext context) {
+               if (checked) {
+                       return !error;
+               }
+
+               checked = true;
+
                if (expression != null) {
                        var switch_statement = (SwitchStatement) section.parent_node;
 
@@ -94,7 +100,10 @@ public class Vala.SwitchLabel : CodeNode {
                                }
                        }
 
-                       expression.check (context);
+                       if (!expression.check (context)) {
+                               error = true;
+                               return false;
+                       }
 
                        if (!expression.is_constant ()) {
                                error = true;
index 0b0a1b1bbebe058e1b626fc149f45a8945c68856..a15b1abe8947991e260fdd494a576ce6a0dcd8b6 100644 (file)
@@ -98,6 +98,12 @@ public class Vala.WhileStatement : CodeNode, Statement {
        }
 
        public override bool check (CodeContext context) {
+               if (checked) {
+                       return !error;
+               }
+
+               checked = true;
+
                // convert to simple loop
 
                if (always_true (condition)) {
@@ -118,7 +124,11 @@ public class Vala.WhileStatement : CodeNode, Statement {
                var parent_block = (Block) parent_node;
                parent_block.replace_statement (this, loop);
 
-               return loop.check (context);
+               if (!loop.check (context)) {
+                       error = true;
+               }
+
+               return !error;
        }
 }