| ... | ... | @@ -678,22 +678,6 @@ test "error union payload is properly aligned" { |
| 678 | 678 | if (blk.a != 1) unreachable; |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | | test "ret_ptr doesn't cause own inferred error set to be resolved" { |
| 682 | | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 683 | | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 684 | | |
| 685 | | const S = struct { |
| 686 | | fn foo() !void {} |
| 687 | | |
| 688 | | fn doTheTest() !void { |
| 689 | | errdefer @compileError("bad"); |
| 690 | | |
| 691 | | return try @This().foo(); |
| 692 | | } |
| 693 | | }; |
| 694 | | try S.doTheTest(); |
| 695 | | } |
| 696 | | |
| 697 | 681 | test "simple else prong allowed even when all errors handled" { |
| 698 | 682 | if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO |
| 699 | 683 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| ... | ... | @@ -889,3 +873,28 @@ test "optional error set return type" { |
| 889 | 873 | try expect(null == S.foo(true)); |
| 890 | 874 | try expect(E.A == S.foo(false).?); |
| 891 | 875 | } |
| 876 | |
| 877 | test "try used in recursive function with inferred error set" { |
| 878 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| 879 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| 880 | |
| 881 | const Value = union(enum) { |
| 882 | values: []const @This(), |
| 883 | b, |
| 884 | |
| 885 | fn x(value: @This()) !void { |
| 886 | switch (value.values[0]) { |
| 887 | .values => return try x(value.values[0]), |
| 888 | .b => return error.a, |
| 889 | } |
| 890 | } |
| 891 | }; |
| 892 | const a = Value{ |
| 893 | .values = &[1]Value{ |
| 894 | .{ |
| 895 | .values = &[1]Value{.{ .b = {} }}, |
| 896 | }, |
| 897 | }, |
| 898 | }; |
| 899 | try expectError(error.a, Value.x(a)); |
| 900 | } |