| 1 | const Enum = enum(u32) { b, a }; |
| 2 | const TaggedUnion = union(Enum) { |
| 3 | b: []const u8, |
| 4 | a: []const u8, |
| 5 | }; |
| 6 | pub export fn entry() void { |
| 7 | const result = TaggedUnion{ .b = "b" }; |
| 8 | _ = result.b; |
| 9 | _ = result.a; |
| 10 | } |
| 11 | pub export fn entry1() void { |
| 12 | const result = TaggedUnion{ .b = "b" }; |
| 13 | _ = &result.b; |
| 14 | _ = &result.a; |
| 15 | } |
| 16 | |
| 17 | // error |
| 18 | // |
| 19 | // :9:15: error: access of union field 'a' while field 'b' is active |
| 20 | // :2:21: note: union declared here |
| 21 | // :14:16: error: access of union field 'a' while field 'b' is active |
| 22 | // :2:21: note: union declared here |