aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/error.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-18 16:24:07 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-05-18 16:24:07 -0700
commitad391ad399b26cf6a781e01c6daecf48bb764478 (patch)
treeda72e64e5c6dd7cbe0c55a901037f4904b12d729 /test/behavior/error.zig
parent3d64ed0353ba7ec1ca46f4779fe5d32af8d17358 (diff)
downloadzig-ad391ad399b26cf6a781e01c6daecf48bb764478.tar.gz
zig-ad391ad399b26cf6a781e01c6daecf48bb764478.zip
Revert "Sema: handle recursive inferred errors better in analyzeIsNonErrComptimeOnly"
This reverts commit 5aa9628de3c6637f45b9d8cf8cbd19c422a74f6f. This is a breaking language change and I do not agree with it. Please go through the proposal process on this one.
Diffstat (limited to 'test/behavior/error.zig')
-rw-r--r--test/behavior/error.zig42
1 files changed, 16 insertions, 26 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index f179739d15..54d53eec4a 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -705,6 +705,22 @@ 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
@@ -912,29 +928,3 @@ 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
- if (builtin.zig_backend == .stage2_spirv64) 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));
-}