diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-07-19 17:45:38 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-07-19 17:45:38 -0700 |
| commit | 1d5f865cfafdaa96cac35ada9bb9e8b1a4e2bc36 (patch) | |
| tree | 2715c03bfc0fff3e2a5845db86019912062d1dfa /src | |
| parent | 046df9b7d001120a0142ea29c86cfb3b9ae4eadf (diff) | |
| download | zig-1d5f865cfafdaa96cac35ada9bb9e8b1a4e2bc36.tar.gz zig-1d5f865cfafdaa96cac35ada9bb9e8b1a4e2bc36.zip | |
Sema: fix runtime instructions omitted
in the presence of comptime control flow.
fixes #12171
Diffstat (limited to 'src')
| -rw-r--r-- | src/Sema.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index c64135f559..3c561821f4 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -4687,6 +4687,10 @@ fn resolveBlockBody( return sema.analyzeBlockBody(parent_block, src, child_block, merges); } else |err| switch (err) { error.ComptimeBreak => { + // Comptime control flow is happening, however child_block may still contain + // runtime instructions which need to be copied to the parent block. + try parent_block.instructions.appendSlice(sema.gpa, child_block.instructions.items); + const break_inst = sema.comptime_break_inst; const break_data = sema.code.instructions.items(.data)[break_inst].@"break"; if (break_data.block_inst == body_inst) { |
