Fix C++ thunk triggering for functions with default args which return a simple type (#6152)

Before this change, we wrongly ignore the decision to generate a thunk
for a function with default args by overriding this decision with the
fact the return type by itself doesn't require a thunk.
This causes not generating a thunk which leads to crashing in lowering.
Add tests that show that now thunk is generated in `check` and it no
longer crashes in `lower`.

Follow up of #6108.
This commit is contained in:
Boaz Brickner
2025-10-02 15:16:28 +00:00
committed by GitHub
parent 16999a79cc
commit 57c0fde145
3 changed files with 491 additions and 295 deletions
+2 -1
View File
@@ -120,7 +120,8 @@ auto IsCppThunkRequired(Context& context, const SemIR::Function& function)
if (return_type_id == SemIR::ErrorInst::TypeId) {
return false;
}
thunk_required = IsThunkRequiredForType(context, return_type_id);
thunk_required =
thunk_required || IsThunkRequiredForType(context, return_type_id);
}
for (auto param_id :