diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-12-28 23:10:48 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-12-28 23:22:09 -0700 |
| commit | efb7148a4574c608b21359fcbf2edf06afdb5e0c (patch) | |
| tree | 23e47a49f95e60ea315603407bd5793310978c62 /test/behavior/switch.zig | |
| parent | 91619cdf57f54accbdbb3ff616856eaf79b537a3 (diff) | |
| download | zig-efb7148a4574c608b21359fcbf2edf06afdb5e0c.tar.gz zig-efb7148a4574c608b21359fcbf2edf06afdb5e0c.zip | |
Sema: more union fixes
* `Module.Union.getLayout`: fixes to support components of the union
being 0 bits.
* Implement `@typeInfo` for unions.
* Add missing calls to `resolveTypeFields`.
* Fix explicitly-provided union tag types passing a `Zir.Inst.Ref`
where an `Air.Inst.Ref` was expected. We don't have any type safety
for this; these typess are aliases.
* Fix explicitly-provided `union(enum)` tag Values allocated to the
wrong arena.
Diffstat (limited to 'test/behavior/switch.zig')
| -rw-r--r-- | test/behavior/switch.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig index 16bb890c9e..caec804ec2 100644 --- a/test/behavior/switch.zig +++ b/test/behavior/switch.zig @@ -313,3 +313,16 @@ fn returnsFalse() bool { test "switch on const enum with var" { try expect(!returnsFalse()); } + +test "anon enum literal used in switch on union enum" { + const Foo = union(enum) { + a: i32, + }; + + var foo = Foo{ .a = 1234 }; + switch (foo) { + .a => |x| { + try expect(x == 1234); + }, + } +} |
