| ... | @@ -896,3 +896,18 @@ test "optional error union return type" { | ... | @@ -896,3 +896,18 @@ test "optional error union return type" { |
| 896 | }; | 896 | }; |
| 897 | try expect(1234 == try S.foo().?); | 897 | try expect(1234 == try S.foo().?); |
| 898 | } | 898 | } |
| | 899 | |
| | 900 | test "optional error set return type" { |
| | 901 | if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO |
| | 902 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO |
| | 903 | |
| | 904 | const E = error{ A, B }; |
| | 905 | const S = struct { |
| | 906 | fn foo(return_null: bool) ?E { |
| | 907 | return if (return_null) null else E.A; |
| | 908 | } |
| | 909 | }; |
| | 910 | |
| | 911 | try expect(null == S.foo(true)); |
| | 912 | try expect(E.A == S.foo(false).?); |
| | 913 | } |