diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-08-21 14:27:34 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-08-22 13:54:14 -0700 |
| commit | ada0010471163a3accca8976185fbb6bb59c914f (patch) | |
| tree | d5035071ea3cb73677e381c0052e137fded064ac /lib/std/meta.zig | |
| parent | 6a5463951f0aa11cbdd5575cc78e85cd2ed10b46 (diff) | |
| download | zig-ada0010471163a3accca8976185fbb6bb59c914f.tar.gz zig-ada0010471163a3accca8976185fbb6bb59c914f.zip | |
compiler: move unions into InternPool
There are a couple concepts here worth understanding:
Key.UnionType - This type is available *before* resolving the union's
fields. The enum tag type, number of fields, and field names, field
types, and field alignments are not available with this.
InternPool.UnionType - This one can be obtained from the above type with
`InternPool.loadUnionType` which asserts that the union's enum tag type
has been resolved. This one has all the information available.
Additionally:
* ZIR: Turn an unused bit into `any_aligned_fields` flag to help
semantic analysis know whether a union has explicit alignment on any
fields (usually not).
* Sema: delete `resolveTypeRequiresComptime` which had the same type
signature and near-duplicate logic to `typeRequiresComptime`.
- Make opaque types not report comptime-only (this was inconsistent
between the two implementations of this function).
* Implement accepted proposal #12556 which is a breaking change.
Diffstat (limited to 'lib/std/meta.zig')
| -rw-r--r-- | lib/std/meta.zig | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 3bc5fc9864..b10ecd2731 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -614,9 +614,9 @@ test "std.meta.FieldEnum" { const Tagged = union(enum) { a: u8, b: void, c: f32 }; try testing.expectEqual(Tag(Tagged), FieldEnum(Tagged)); - const Tag2 = enum { b, c, a }; + const Tag2 = enum { a, b, c }; const Tagged2 = union(Tag2) { a: u8, b: void, c: f32 }; - try testing.expect(Tag(Tagged2) != FieldEnum(Tagged2)); + try testing.expect(Tag(Tagged2) == FieldEnum(Tagged2)); const Tag3 = enum(u8) { a, b, c = 7 }; const Tagged3 = union(Tag3) { a: u8, b: void, c: f32 }; |
