| author | |
| committer | |
| log | 7f91be9c80f8d79e4a2c6cf0b15197cdd454cef6 |
| tree | 3356aeb0462c236f4e9af621415ad4582ea4f832 |
| parent | bcf2eb1a003d076c166d4ce9cba20f6ed9b53887 |
2 files changed, 12 insertions(+), 2 deletions(-)
src/AstGen.zig+2-2| ... | ... | @@ -1878,8 +1878,8 @@ fn continueExpr(parent_gz: *GenZir, parent_scope: *Scope, node: Ast.Node.Index) |
| 1878 | 1878 | continue; |
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | // TODO emit a break_inline if the loop being continued is inline | |
| 1882 | _ = try parent_gz.addBreak(.@"break", continue_block, .void_value); | |
| 1881 | const break_tag: Zir.Inst.Tag = if (gen_zir.is_inline) .break_inline else .@"break"; | |
| 1882 | _ = try parent_gz.addBreak(break_tag, continue_block, .void_value); | |
| 1883 | 1883 | return Zir.Inst.Ref.unreachable_value; |
| 1884 | 1884 | }, |
| 1885 | 1885 | .local_val => scope = scope.cast(Scope.LocalVal).?.parent, |
test/behavior/while.zig+10| ... | ... | @@ -1,6 +1,7 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | 2 | const builtin = @import("builtin"); |
| 3 | 3 | const expect = std.testing.expect; |
| 4 | const assert = std.debug.assert; | |
| 4 | 5 | |
| 5 | 6 | test "while loop" { |
| 6 | 7 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| ... | ... | @@ -326,3 +327,12 @@ test "while error 2 break statements and an else" { |
| 326 | 327 | try S.entry(true, false); |
| 327 | 328 | comptime try S.entry(true, false); |
| 328 | 329 | } |
| 330 | ||
| 331 | test "continue inline while loop" { | |
| 332 | comptime var i = 0; | |
| 333 | inline while (i < 10) : (i += 1) { | |
| 334 | if (i < 5) continue; | |
| 335 | break; | |
| 336 | } | |
| 337 | comptime assert(i == 5); | |
| 338 | } |