aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-03-12 14:18:58 -0500
committerGitHub <noreply@github.com>2022-03-12 14:18:58 -0500
commit5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63 (patch)
treea4bffd48c7c31b64af53425464e0c0c048156abf /test
parent01081ce5a59f4e2e57a9ff6e5885269ed3014279 (diff)
parentd532c21d890e1aa22cd4c57d6a3f749890256254 (diff)
downloadzig-5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63.tar.gz
zig-5ff7b04a6ad72eb86b6d467dfdc25bea1a9ecf63.zip
Merge pull request #11133 from Vexu/stage2
stage2: misc fixes on the way to `std.debug.dumpCurrentStackTrace`
Diffstat (limited to 'test')
-rw-r--r--test/behavior/error.zig23
-rw-r--r--test/behavior/switch.zig5
2 files changed, 24 insertions, 4 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index b3503051fb..e6c69f4abf 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -626,3 +626,26 @@ test "inferred error set equality" {
try expect(BarError == BarError);
try expect(BazError == BazError);
}
+
+test "peer type resolution of two different error unions" {
+ const a: error{B}!void = {};
+ const b: error{A}!void = {};
+ var cond = true;
+ const err = if (cond) a else b;
+ try err;
+}
+
+test "coerce error set to the current inferred error set" {
+ const S = struct {
+ fn foo() !void {
+ var a = false;
+ if (a) {
+ const b: error{A}!void = error.A;
+ return b;
+ }
+ const b = error.A;
+ return b;
+ }
+ };
+ S.foo() catch {};
+}
diff --git a/test/behavior/switch.zig b/test/behavior/switch.zig
index d99998a34e..5c47a24b38 100644
--- a/test/behavior/switch.zig
+++ b/test/behavior/switch.zig
@@ -610,14 +610,11 @@ test "switch on pointer type" {
}
test "switch on error set with single else" {
- if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
-
const S = struct {
fn doTheTest() !void {
var some: error{Foo} = error.Foo;
try expect(switch (some) {
- else => |a| blk: {
- a catch {};
+ else => blk: {
break :blk true;
},
});