Remove null-casts for anyerr.

This commit is contained in:
Christoffer Lerno
2023-03-15 16:28:48 +01:00
parent e2b9a35dfe
commit 7075f834dd
2 changed files with 2 additions and 9 deletions

View File

@@ -1004,13 +1004,6 @@ static bool cast_from_pointer(SemaContext *context, Expr *expr, Type *from, Type
return cast_with_optional(expr, to_type, add_optional);
}
return sema_error_cannot_convert(expr, to_type, true, silent);
case TYPE_FAULTTYPE:
case TYPE_ANYERR:
if (expr_is_const_pointer(expr) && !expr->const_expr.ptr)
{
expr_rewrite_to_const_zero(expr, to_type);
return true;
}
case TYPE_OPTIONAL_ANY:
case TYPE_OPTIONAL:
UNREACHABLE

View File

@@ -8,11 +8,11 @@ fault Foo
fn void ordinals()
{
Foo z = null;
Foo z = {};
assert(z.ordinal == 0);
$assert(Foo.ABC.ordinal == 1);
$assert(Foo.CDE.ordinal == 2);
$assert(((Foo)null).ordinal == 0);
$assert((Foo{}).ordinal == 0);
Foo x = Foo.CDE;
assert(x.ordinal == 2);
x = Foo.ABC;