@@ -9003,6 +9003,9 @@ fn zirSwitchCond(
|
||||
.ErrorSet,
|
||||
.Enum,
|
||||
=> {
|
||||
if (operand_ty.isSlice()) {
|
||||
return sema.fail(block, src, "switch on type '{}'", .{operand_ty.fmt(sema.mod)});
|
||||
}
|
||||
if ((try sema.typeHasOnePossibleValue(block, operand_src, operand_ty))) |opv| {
|
||||
return sema.addConstant(operand_ty, opv);
|
||||
}
|
||||
|
||||
13
test/cases/compile_errors/switch_on_slice.zig
Normal file
13
test/cases/compile_errors/switch_on_slice.zig
Normal file
@@ -0,0 +1,13 @@
|
||||
pub export fn entry() void {
|
||||
var a: [:0]const u8 = "foo";
|
||||
switch (a) {
|
||||
"--version", "version" => unreachable,
|
||||
else => {},
|
||||
}
|
||||
}
|
||||
|
||||
// error
|
||||
// backend=stage2
|
||||
// target=native
|
||||
//
|
||||
// :3:13: error: switch on type '[:0]const u8'
|
||||
Reference in New Issue
Block a user