mirror of
https://github.com/ziglang/zig.git
synced 2025-01-21 17:31:12 +00:00
parent
6b037bad59
commit
8b35f09f4a
@ -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 => {
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user