Commit 81664f17d5
Changed files (2)
src
test
behavior
src/codegen.zig
@@ -1189,12 +1189,16 @@ pub fn genTypedValue(
.enum_simple => {
return GenResult.mcv(.{ .immediate = field_index.data });
},
- .enum_full, .enum_nonexhaustive => {
- const enum_full = typed_value.ty.cast(Type.Payload.EnumFull).?.data;
- if (enum_full.values.count() != 0) {
- const tag_val = enum_full.values.keys()[field_index.data];
+ .enum_numbered, .enum_full, .enum_nonexhaustive => {
+ const enum_values = if (typed_value.ty.castTag(.enum_numbered)) |pl|
+ pl.data.values
+ else
+ typed_value.ty.cast(Type.Payload.EnumFull).?.data.values;
+ if (enum_values.count() != 0) {
+ const tag_val = enum_values.keys()[field_index.data];
+ var buf: Type.Payload.Bits = undefined;
return genTypedValue(bin_file, src_loc, .{
- .ty = enum_full.tag_ty,
+ .ty = typed_value.ty.intTagType(&buf),
.val = tag_val,
}, owner_decl_index);
} else {
test/behavior/union.zig
@@ -362,7 +362,6 @@ const MultipleChoice = union(enum(u32)) {
D = 1000,
};
test "simple union(enum(u32))" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
@@ -641,7 +640,6 @@ test "tagged union with all void fields but a meaningful tag" {
}
test "union(enum(u32)) with specified and unspecified tag values" {
- if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO