From 1d5f865cfafdaa96cac35ada9bb9e8b1a4e2bc36 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 19 Jul 2022 17:45:38 -0700 Subject: Sema: fix runtime instructions omitted in the presence of comptime control flow. fixes #12171 --- src/Sema.zig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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) { -- cgit v1.2.3