diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-11-05 12:51:32 +0200 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2022-11-05 13:22:21 +0200 |
| commit | 5d28d171dffd5a03276e04ec7089593e967630df (patch) | |
| tree | bb2bc9117040ccc00c212ec42cff4a436311c935 /test | |
| parent | ea48f06fc2965ff2e9516c23e58a50a9db5da84b (diff) | |
| download | zig-5d28d171dffd5a03276e04ec7089593e967630df.tar.gz zig-5d28d171dffd5a03276e04ec7089593e967630df.zip | |
Sema: adjust result type of anyerror field access
Closes #13448
Diffstat (limited to 'test')
| -rw-r--r-- | test/behavior/error.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig index 2013cbcfa3..25feb101bc 100644 --- a/test/behavior/error.zig +++ b/test/behavior/error.zig @@ -855,3 +855,13 @@ test "error from comptime string" { try expect(mem.eql(u8, name, @errorName(err))); } } + +test "field access of anyerror results in smaller error set" { + if (builtin.zig_backend == .stage1) return error.SkipZigTest; + + const E1 = @TypeOf(error.Foo); + try expect(@TypeOf(E1.Foo) == E1); + const E2 = error{ A, B, C }; + try expect(@TypeOf(E2.A) == E2); + try expect(@TypeOf(@field(anyerror, "NotFound")) == error{NotFound}); +} |
