Sema: check error union payload types in @errorCast

This commit is contained in:
Veikka Tuominen
2024-03-28 15:37:48 +02:00
parent 60614b2a85
commit 9106fdffaf
2 changed files with 23 additions and 0 deletions

View File

@@ -13,6 +13,11 @@ export fn entry3() void {
const a: anyerror = @errorCast(e);
_ = a;
}
pub export fn entry4() void {
const a: anyerror!u32 = 123;
const b: anyerror!f32 = @errorCast(a);
_ = b;
}
// error
// backend=stage2
@@ -21,3 +26,6 @@ export fn entry3() void {
// :4:25: error: expected error set or error union type, found 'ComptimeInt'
// :8:20: error: expected error set or error union type, found 'Int'
// :13:25: error: cannot cast an error union type to error set
// :18:29: error: payload types of error unions must match
// :18:29: note: destination payload is 'f32'
// :18:29: note: operand payload is 'u32'