aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-07 22:19:17 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-04-07 22:19:17 -0700
commit57aa289fdef543a507d8da039f5b7e7f2762c878 (patch)
tree1e8f3c072f2c004554880cd23e53337bbc24a39b /src
parente730172e47749db8a9d3be5949231bde95343b39 (diff)
downloadzig-57aa289fdef543a507d8da039f5b7e7f2762c878.tar.gz
zig-57aa289fdef543a507d8da039f5b7e7f2762c878.zip
Sema: fix switch validation '_' prong on wrong type
Diffstat (limited to 'src')
-rw-r--r--src/Sema.zig4
-rw-r--r--src/type.zig4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/Sema.zig b/src/Sema.zig
index a0be08ed71..519d5df401 100644
--- a/src/Sema.zig
+++ b/src/Sema.zig
@@ -1972,7 +1972,7 @@ fn zirIntToEnum(sema: *Sema, block: *Scope.Block, inst: zir.Inst.Index) InnerErr
return mod.fail(&block.base, dest_ty_src, "expected enum, found {}", .{dest_ty});
}
- if (!dest_ty.isExhaustiveEnum()) {
+ if (dest_ty.isNonexhaustiveEnum()) {
if (operand.value()) |int_val| {
return mod.constInst(arena, src, .{
.ty = dest_ty,
@@ -2762,7 +2762,7 @@ fn analyzeSwitch(
const operand_src: LazySrcLoc = .{ .node_offset_switch_operand = src_node_offset };
// Validate usage of '_' prongs.
- if (special_prong == .under and !operand.ty.isExhaustiveEnum()) {
+ if (special_prong == .under and !operand.ty.isNonexhaustiveEnum()) {
const msg = msg: {
const msg = try mod.errMsg(
&block.base,
diff --git a/src/type.zig b/src/type.zig
index 1e52d2eb74..ab31991c36 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -2119,9 +2119,9 @@ pub const Type = extern union {
}
}
- pub fn isExhaustiveEnum(ty: Type) bool {
+ pub fn isNonexhaustiveEnum(ty: Type) bool {
return switch (ty.tag()) {
- .enum_full, .enum_simple => true,
+ .enum_nonexhaustive => true,
else => false,
};
}