diff --git a/src/Sema.zig b/src/Sema.zig index 4e479d263a..21e6fd14be 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -11288,6 +11288,7 @@ fn resolveSwitchItemVal( // Only if we know for sure we need to report a compile error do we resolve the // full source locations. if (sema.resolveConstValue(block, .unneeded, item, "")) |val| { + try sema.resolveLazyValue(val); return TypedValue{ .ty = item_ty, .val = val }; } else |err| switch (err) { error.NeededSourceLocation => { diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index 3bb9c35a4e..b8c367eb44 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -686,3 +686,17 @@ test "enum value without tag name used as switch item" { _ => return error.TestFailed, } } + +test "switch item sizeof" { + const S = struct { + fn doTheTest() !void { + var a: usize = 0; + switch (a) { + @sizeOf(struct {}) => {}, + else => return error.TestFailed, + } + } + }; + try S.doTheTest(); + comptime try S.doTheTest(); +}