aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/while.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-07-13 15:59:46 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-07-13 16:10:41 -0700
commitfad95741db7529bbad873fb330c25d64ac765340 (patch)
tree22ca663d66d22bccc6ffe9ac0d2c676ed8bb0636 /test/behavior/while.zig
parent1fee9eac8bb5d2e3e78c098b9cebe2cda332e7cf (diff)
downloadzig-fad95741db7529bbad873fb330c25d64ac765340.tar.gz
zig-fad95741db7529bbad873fb330c25d64ac765340.zip
AstGen: fix loop control flow applying to wrong loop
In the case of 'continue' or 'break' inside the 'else' block of a 'while' or 'for' loop. Closes #12109
Diffstat (limited to 'test/behavior/while.zig')
-rw-r--r--test/behavior/while.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/behavior/while.zig b/test/behavior/while.zig
index b664e73b89..62d5bf90fa 100644
--- a/test/behavior/while.zig
+++ b/test/behavior/while.zig
@@ -334,3 +334,13 @@ test "continue inline while loop" {
}
comptime assert(i == 5);
}
+
+test "else continue outer while" {
+ var i: usize = 0;
+ while (true) {
+ i += 1;
+ while (i > 5) {
+ return;
+ } else continue;
+ }
+}