From 8ec4c5cb137d9a93c35df3488408c44056c586b4 Mon Sep 17 00:00:00 2001 From: Matthew Lugg Date: Sun, 11 Jan 2026 11:36:51 +0000 Subject: [PATCH] Sema: evaluate switch items at comptime --- src/Sema.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Sema.zig b/src/Sema.zig index 29c5c14702f6d3176a3b8de8e3cf694b4f59e887..204d4a736c1001c40abfd452ffa0b8040c589270 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -13210,6 +13210,12 @@ fn resolveSwitchItem( // The result location of item bodies is `.{ .coerce_ty = switch_inst }`. sema.inst_map.putAssumeCapacity(switch_inst, .fromType(item_ty)); defer assert(sema.inst_map.remove(switch_inst)); + const old_comptime_reason = block.comptime_reason; + defer block.comptime_reason = old_comptime_reason; + block.comptime_reason = .{ .reason = .{ + .src = item_src, + .r = .{ .simple = .switch_item }, + } }; break :ref try sema.resolveInlineBody(block, body, switch_inst); }; break :uncoerced .{ uncoerced, sema.typeOf(uncoerced) }; -- 2.54.0