| author | |
| committer | |
| log | 81664f17d5ec4382057bc3d2c8774d8804791a04 |
| tree | 944f5df8addce217e221c0c867b3b9781cce6048 |
| parent | e36e9323f4c4ce66013ba4774ff0145fc9cad34d |
2 files changed, 9 insertions(+), 7 deletions(-)
src/codegen.zig+9-5| ... | ... | @@ -1189,12 +1189,16 @@ pub fn genTypedValue( |
| 1189 | 1189 | .enum_simple => { |
| 1190 | 1190 | return GenResult.mcv(.{ .immediate = field_index.data }); |
| 1191 | 1191 | }, |
| 1192 | .enum_full, .enum_nonexhaustive => { | |
| 1193 | const enum_full = typed_value.ty.cast(Type.Payload.EnumFull).?.data; | |
| 1194 | if (enum_full.values.count() != 0) { | |
| 1195 | const tag_val = enum_full.values.keys()[field_index.data]; | |
| 1192 | .enum_numbered, .enum_full, .enum_nonexhaustive => { | |
| 1193 | const enum_values = if (typed_value.ty.castTag(.enum_numbered)) |pl| | |
| 1194 | pl.data.values | |
| 1195 | else | |
| 1196 | typed_value.ty.cast(Type.Payload.EnumFull).?.data.values; | |
| 1197 | if (enum_values.count() != 0) { | |
| 1198 | const tag_val = enum_values.keys()[field_index.data]; | |
| 1199 | var buf: Type.Payload.Bits = undefined; | |
| 1196 | 1200 | return genTypedValue(bin_file, src_loc, .{ |
| 1197 | .ty = enum_full.tag_ty, | |
| 1201 | .ty = typed_value.ty.intTagType(&buf), | |
| 1198 | 1202 | .val = tag_val, |
| 1199 | 1203 | }, owner_decl_index); |
| 1200 | 1204 | } else { |
test/behavior/union.zig-2| ... | ... | @@ -362,7 +362,6 @@ const MultipleChoice = union(enum(u32)) { |
| 362 | 362 | D = 1000, |
| 363 | 363 | }; |
| 364 | 364 | test "simple union(enum(u32))" { |
| 365 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 366 | 365 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 367 | 366 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 368 | 367 | 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" { |
| 641 | 640 | } |
| 642 | 641 | |
| 643 | 642 | test "union(enum(u32)) with specified and unspecified tag values" { |
| 644 | if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; | |
| 645 | 643 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; |
| 646 | 644 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; |
| 647 | 645 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |