Sema: fix issues in @errorCast with error unions
This commit is contained in:
committed by
Andrew Kelley
parent
c9c3ee704c
commit
0bdbd3e235
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user