| author | |
| committer | |
| log | 6cbb732b59d1ded92c7272a8b06f645e1c8acfd2 |
| tree | 2e8e256c26ffd1bc2c7d58850588696ee4b9f857 |
| parent | 4e81df12c3dae2ae67ef25fcfe65e8db724e84f3 |
Fixes #33782 files changed, 11 insertions(+), 1 deletions(-)
src/ir.cpp+1-1| ... | ... | @@ -17951,7 +17951,7 @@ static IrInstruction *ir_analyze_container_field_ptr(IrAnalyze *ira, Buf *field_ |
| 17951 | 17951 | union_val->special = ConstValSpecialStatic; |
| 17952 | 17952 | bigint_init_bigint(&union_val->data.x_union.tag, &field->enum_field->value); |
| 17953 | 17953 | union_val->data.x_union.payload = payload_val; |
| 17954 | } else { | |
| 17954 | } else if (bare_type->data.unionation.layout != ContainerLayoutExtern) { | |
| 17955 | 17955 | TypeUnionField *actual_field = find_union_field_by_tag(bare_type, &union_val->data.x_union.tag); |
| 17956 | 17956 | if (actual_field == nullptr) |
| 17957 | 17957 | zig_unreachable(); |
test/stage1/behavior/union.zig+10| ... | ... | @@ -511,3 +511,13 @@ test "union with comptime_int tag" { |
| 511 | 511 | }; |
| 512 | 512 | comptime expect(@TagType(@TagType(Union)) == comptime_int); |
| 513 | 513 | } |
| 514 | ||
| 515 | test "extern union doesn't trigger field check at comptime" { | |
| 516 | const U = extern union { | |
| 517 | x: u32, | |
| 518 | y: u8, | |
| 519 | }; | |
| 520 | ||
| 521 | const x = U{ .x = 0x55AAAA55 }; | |
| 522 | comptime expect(x.y == 0x55); | |
| 523 | } |