unreachable return type can cast to any other return type

master
Andrew Kelley 2016-02-07 00:23:05 -07:00
parent fc31096519
commit 4174134108
2 changed files with 16 additions and 2 deletions

View File

@ -1655,8 +1655,10 @@ static bool types_match_const_cast_only(TypeTableEntry *expected_type, TypeTable
if (expected_type->data.fn.fn_type_id.is_cold != actual_type->data.fn.fn_type_id.is_cold) {
return false;
}
if (!types_match_const_cast_only(expected_type->data.fn.fn_type_id.return_type,
actual_type->data.fn.fn_type_id.return_type))
if (actual_type->data.fn.fn_type_id.return_type->id != TypeTableEntryIdUnreachable &&
!types_match_const_cast_only(
expected_type->data.fn.fn_type_id.return_type,
actual_type->data.fn.fn_type_id.return_type))
{
return false;
}

View File

@ -196,3 +196,15 @@ fn rhs_maybe_unwrap_return() {
const x = ?true;
const y = x ?? return;
}
#attribute("test")
fn implicit_cast_fn_unreachable_return() {
wants_fn_with_void(fn_with_unreachable);
}
fn wants_fn_with_void(f: fn()) { }
fn fn_with_unreachable() -> unreachable {
unreachable {}
}