authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-11 11:36:51+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-01-11 14:34:19+00:00
log8ec4c5cb137d9a93c35df3488408c44056c586b4
tree1a3e8d10597a9f827178bc120106a66e100a2c36
parent078e100573443488837e317b64bf00c704ee2a46
signaturelock-open Commit is signed but in an unrecognized format.

Sema: evaluate switch items at comptime


1 files changed, 6 insertions(+), 0 deletions(-)

src/Sema.zig+6
...@@ -13210,6 +13210,12 @@ fn resolveSwitchItem(...@@ -13210,6 +13210,12 @@ fn resolveSwitchItem(
13210 // The result location of item bodies is `.{ .coerce_ty = switch_inst }`.13210 // The result location of item bodies is `.{ .coerce_ty = switch_inst }`.
13211 sema.inst_map.putAssumeCapacity(switch_inst, .fromType(item_ty));13211 sema.inst_map.putAssumeCapacity(switch_inst, .fromType(item_ty));
13212 defer assert(sema.inst_map.remove(switch_inst));13212 defer assert(sema.inst_map.remove(switch_inst));
13213 const old_comptime_reason = block.comptime_reason;
13214 defer block.comptime_reason = old_comptime_reason;
13215 block.comptime_reason = .{ .reason = .{
13216 .src = item_src,
13217 .r = .{ .simple = .switch_item },
13218 } };
13213 break :ref try sema.resolveInlineBody(block, body, switch_inst);13219 break :ref try sema.resolveInlineBody(block, body, switch_inst);
13214 };13220 };
13215 break :uncoerced .{ uncoerced, sema.typeOf(uncoerced) };13221 break :uncoerced .{ uncoerced, sema.typeOf(uncoerced) };