aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/error.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2023-10-02 15:44:50 +0300
committerAndrew Kelley <andrew@ziglang.org>2023-10-03 00:45:48 -0700
commit0bdbd3e235daee64caf1f99e5b9d7b62f4c5c484 (patch)
tree374a407a0db101d2d17fc358e4b0d30dbc8b1c9d /test/behavior/error.zig
parentc9c3ee704c45efe0e19bd02c08f51c7513268e76 (diff)
downloadzig-0bdbd3e235daee64caf1f99e5b9d7b62f4c5c484.tar.gz
zig-0bdbd3e235daee64caf1f99e5b9d7b62f4c5c484.zip
Sema: fix issues in `@errorCast` with error unions
Diffstat (limited to 'test/behavior/error.zig')
-rw-r--r--test/behavior/error.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/test/behavior/error.zig b/test/behavior/error.zig
index 2c3ba3b8c7..c0725f8779 100644
--- a/test/behavior/error.zig
+++ b/test/behavior/error.zig
@@ -238,13 +238,23 @@ fn testExplicitErrorSetCast(set1: Set1) !void {
test "@errorCast on error unions" {
const S = struct {
fn doTheTest() !void {
- const casted: error{Bad}!i32 = @errorCast(retErrUnion());
- try expect((try casted) == 1234);
+ {
+ const casted: error{Bad}!i32 = @errorCast(retErrUnion());
+ try expect((try casted) == 1234);
+ }
+ {
+ const casted: error{Bad}!i32 = @errorCast(retInferredErrUnion());
+ try expect((try casted) == 5678);
+ }
}
fn retErrUnion() anyerror!i32 {
return 1234;
}
+
+ fn retInferredErrUnion() !i32 {
+ return 5678;
+ }
};
try S.doTheTest();