aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/error.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-10-06 17:46:02 +0300
committerVeikka Tuominen <git@vexu.eu>2022-10-07 11:04:02 +0300
commit4a6cc1c602a08ddff6c498d8c37919c5c0c842f0 (patch)
tree69b38e06390a41c3140a61268222a256ea814c09 /test/behavior/error.zig
parent2315e1b41073a8d6a7f7fe3deb98ec98e45d72f6 (diff)
downloadzig-4a6cc1c602a08ddff6c498d8c37919c5c0c842f0.tar.gz
zig-4a6cc1c602a08ddff6c498d8c37919c5c0c842f0.zip
Sema: allow equality comparisons between error unions and error sets
Closes #1302
Diffstat (limited to 'test/behavior/error.zig')
-rw-r--r--test/behavior/error.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index dc29c9bc5b..ba5bdfdc20 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -809,3 +809,24 @@ test "alignment of wrapping an error union payload" {
};
try expect((S.foo() catch unreachable).x == 1234);
}
+
+test "compare error union and error set" {
+ if (builtin.zig_backend == .stage1) return error.SkipZigTest;
+ if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
+
+ var a: anyerror = error.Foo;
+ var b: anyerror!u32 = error.Bar;
+
+ try expect(a != b);
+ try expect(b != a);
+
+ b = error.Foo;
+
+ try expect(a == b);
+ try expect(b == a);
+
+ b = 2;
+
+ try expect(a != b);
+ try expect(b != a);
+}