diff --git a/src/analyze.cpp b/src/analyze.cpp index 4f980df9d5..bd31abd6a7 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -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; } diff --git a/test/self_hosted.zig b/test/self_hosted.zig index 57125f398b..1f937b441b 100644 --- a/test/self_hosted.zig +++ b/test/self_hosted.zig @@ -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 {} +}