InternPool: add representation for value of empty enums and unions

This is a bit odd, because this value doesn't actually exist:
see #15909. This gets all the empty enum/union behavior tests passing.

Also adds an assertion to `Sema.analyzeBodyInner` which would have
helped figure out the issue here much more quickly.
This commit is contained in:
mlugg
2023-05-31 04:42:18 +01:00
committed by Andrew Kelley
parent 99531b0d52
commit a0d4ef0acf
10 changed files with 66 additions and 13 deletions

View File

@@ -946,6 +946,7 @@ pub const DeclGen = struct {
.extern_func,
.func,
.enum_literal,
.empty_enum_value,
=> unreachable, // non-runtime values
.int => |int| switch (int.storage) {
.u64, .i64, .big_int => try writer.print("{}", .{try dg.fmtIntLiteral(ty, val, location)}),

View File

@@ -3246,6 +3246,7 @@ pub const DeclGen = struct {
},
.variable,
.enum_literal,
.empty_enum_value,
=> unreachable, // non-runtime values
.extern_func, .func => {
const fn_decl_index = switch (val_key) {

View File

@@ -660,6 +660,7 @@ pub const DeclGen = struct {
.extern_func,
.func,
.enum_literal,
.empty_enum_value,
=> unreachable, // non-runtime values
.int => try self.addInt(ty, val),
.err => |err| {