aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/union.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-12 11:36:26 -0700
committerAndrew Kelley <andrew@ziglang.org>2022-04-12 11:36:26 -0700
commit99657dca1fac04e5015203699e3eb0d656d66b09 (patch)
treef7265547fc92b7797a6d695ab271f2e92d43f4fd /test/behavior/union.zig
parentb0edd8752a00ea191decf302d9802b853d85fd4c (diff)
downloadzig-99657dca1fac04e5015203699e3eb0d656d66b09.tar.gz
zig-99657dca1fac04e5015203699e3eb0d656d66b09.zip
Sema: fix comptime equality of extern unions with same tag
Diffstat (limited to 'test/behavior/union.zig')
-rw-r--r--test/behavior/union.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/union.zig b/test/behavior/union.zig
index 87efcbd5f1..8315ea8a22 100644
--- a/test/behavior/union.zig
+++ b/test/behavior/union.zig
@@ -1168,3 +1168,18 @@ test "union with a large struct field" {
var s: S = undefined;
U.foo(U{ .s = s });
}
+
+test "comptime equality of extern unions with same tag" {
+ const S = struct {
+ const U = extern union {
+ a: i32,
+ b: f32,
+ };
+ fn foo(comptime x: U) i32 {
+ return x.a;
+ }
+ };
+ const a = S.U{ .a = 1234 };
+ const b = S.U{ .a = 1234 };
+ try expect(S.foo(a) == S.foo(b));
+}