mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Track complete types required by a generic. (#4652)
When a generic requires a symbolic type to be complete, add a new `require_complete_type` instruction to the generic eval block. During monomorphization of such an instruction, require that type to be complete.
This commit is contained in:
@@ -331,16 +331,17 @@ auto HandleParseNode(Context& context, Parse::FunctionDeclId node_id) -> bool {
|
||||
static auto CheckFunctionDefinitionSignature(Context& context,
|
||||
SemIR::Function& function)
|
||||
-> void {
|
||||
// Check the return type is complete.
|
||||
CheckFunctionReturnType(context, function.return_slot_pattern_id, function,
|
||||
SemIR::SpecificId::Invalid);
|
||||
|
||||
auto params_to_complete =
|
||||
context.inst_blocks().GetOrEmpty(function.call_params_id);
|
||||
|
||||
// Check the return type is complete.
|
||||
if (function.return_slot_pattern_id.is_valid()) {
|
||||
// Exclude the return slot because it's diagnosed above.
|
||||
CheckFunctionReturnType(
|
||||
context, context.insts().GetLocId(function.return_slot_pattern_id),
|
||||
function, SemIR::SpecificId::Invalid);
|
||||
params_to_complete = params_to_complete.drop_back();
|
||||
}
|
||||
|
||||
// Check the parameter types are complete.
|
||||
for (auto param_ref_id : params_to_complete) {
|
||||
if (param_ref_id == SemIR::ErrorInst::SingletonInstId) {
|
||||
@@ -349,7 +350,8 @@ static auto CheckFunctionDefinitionSignature(Context& context,
|
||||
|
||||
// The parameter types need to be complete.
|
||||
context.TryToCompleteType(
|
||||
context.insts().GetAs<SemIR::AnyParam>(param_ref_id).type_id, [&] {
|
||||
context.insts().GetAs<SemIR::AnyParam>(param_ref_id).type_id,
|
||||
context.insts().GetLocId(param_ref_id), [&] {
|
||||
CARBON_DIAGNOSTIC(
|
||||
IncompleteTypeInFunctionParam, Error,
|
||||
"parameter has incomplete type {0} in function definition",
|
||||
|
||||
Reference in New Issue
Block a user