Skip to content

Commit 0adbfc2

Browse files
committed
Sema: add @errorCast which works for both error sets and error unions
Closes ziglang#17343
1 parent 0dd18c1 commit 0adbfc2

3 files changed

+3
-3
lines changed

compile_errors/explicit_error_set_cast_known_at_comptime_violates_error_sets.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const Set1 = error{ A, B };
22
const Set2 = error{ A, C };
33
comptime {
44
var x = Set1.B;
5-
var y: Set2 = @errSetCast(x);
5+
var y: Set2 = @errorCast(x);
66
_ = y;
77
}
88

compile_errors/int_to_err_non_global_invalid_number.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const Set2 = error{
88
};
99
comptime {
1010
var x = @intFromError(Set1.B);
11-
var y: Set2 = @errSetCast(@errorFromInt(x));
11+
var y: Set2 = @errorCast(@errorFromInt(x));
1212
_ = y;
1313
}
1414

safety/@errSetCast error not present in destination.zig safety/@errorCast error not present in destination.zig

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn main() !void {
1414
return error.TestFailed;
1515
}
1616
fn foo(set1: Set1) Set2 {
17-
return @errSetCast(set1);
17+
return @errorCast(set1);
1818
}
1919
// run
2020
// backend=llvm

0 commit comments

Comments
 (0)