| author | |
| committer | |
| log | 8b35f09f4ae29eb2768d47e8a8bae0f4131d6bad |
| tree | ef55b1531dcc83b33e76f71847d88c57f13d56ea |
| parent | 6b037bad590bd6c319af336b6d3017c33d6834ba |
Closes #143302 files changed, 15 insertions(+), 0 deletions(-)
src/Sema.zig+1| ... | ... | @@ -11288,6 +11288,7 @@ fn resolveSwitchItemVal( |
| 11288 | 11288 | // Only if we know for sure we need to report a compile error do we resolve the |
| 11289 | 11289 | // full source locations. |
| 11290 | 11290 | if (sema.resolveConstValue(block, .unneeded, item, "")) |val| { |
| 11291 | try sema.resolveLazyValue(val); | |
| 11291 | 11292 | return TypedValue{ .ty = item_ty, .val = val }; |
| 11292 | 11293 | } else |err| switch (err) { |
| 11293 | 11294 | error.NeededSourceLocation => { |
test/behavior/switch.zig+14| ... | ... | @@ -686,3 +686,17 @@ test "enum value without tag name used as switch item" { |
| 686 | 686 | _ => return error.TestFailed, |
| 687 | 687 | } |
| 688 | 688 | } |
| 689 | ||
| 690 | test "switch item sizeof" { | |
| 691 | const S = struct { | |
| 692 | fn doTheTest() !void { | |
| 693 | var a: usize = 0; | |
| 694 | switch (a) { | |
| 695 | @sizeOf(struct {}) => {}, | |
| 696 | else => return error.TestFailed, | |
| 697 | } | |
| 698 | } | |
| 699 | }; | |
| 700 | try S.doTheTest(); | |
| 701 | comptime try S.doTheTest(); | |
| 702 | } |