diff options
| author | Veikka Tuominen <git@vexu.eu> | 2023-05-13 12:52:16 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-13 12:52:16 +0300 |
| commit | 68bacad8047df050c8ab6bf52c2921f482647d57 (patch) | |
| tree | 9b428c397ee0173b670dfbe34f4c9330dc257bb7 /test/behavior/error.zig | |
| parent | 6f418c11e1ad1150fbdb002cfe1be92bda4e93cb (diff) | |
| parent | 5aa9628de3c6637f45b9d8cf8cbd19c422a74f6f (diff) | |
| download | zig-68bacad8047df050c8ab6bf52c2921f482647d57.tar.gz zig-68bacad8047df050c8ab6bf52c2921f482647d57.zip | |
Merge pull request #15643 from Vexu/fixes
make `@call` compile errors match regular calls
Diffstat (limited to 'test/behavior/error.zig')
| -rw-r--r-- | test/behavior/error.zig | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig index 54d53eec4a..7e457c6456 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -705,22 +705,6 @@ test "error union payload is properly aligned" { if (blk.a != 1) unreachable; } -test "ret_ptr doesn't cause own inferred error set to be resolved" { - if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO - if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO - - const S = struct { - fn foo() !void {} - - fn doTheTest() !void { - errdefer @compileError("bad"); - - return try @This().foo(); - } - }; - try S.doTheTest(); -} - test "simple else prong allowed even when all errors handled" { if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO @@ -928,3 +912,28 @@ test "optional error set return type" { try expect(null == S.foo(true)); try expect(E.A == S.foo(false).?); } + +test "try used in recursive function with inferred error set" { + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + + const Value = union(enum) { + values: []const @This(), + b, + + fn x(value: @This()) !void { + switch (value.values[0]) { + .values => return try x(value.values[0]), + .b => return error.a, + } + } + }; + const a = Value{ + .values = &[1]Value{ + .{ + .values = &[1]Value{.{ .b = {} }}, + }, + }, + }; + try expectError(error.a, Value.x(a)); +} |
