mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Decouple PerformCallToFunction from ReturnTypeInfo (#6572)
`ReturnTypeInfo` is built around the assumption that a function call results in exactly one initializing expression, but with `ref` returns there may be zero, and in the future composite return forms will enable there to be more than one. This change removes some usages of `ReturnTypeInfo`, and restructures the calling code to be prepared for multiple initializing returns.
This commit is contained in:
@@ -629,17 +629,22 @@ auto CallerPatternMatch(Context& context, SemIR::SpecificId specific_id,
|
||||
SemIR::InstBlockId return_patterns_id,
|
||||
SemIR::InstId self_arg_id,
|
||||
llvm::ArrayRef<SemIR::InstId> arg_refs,
|
||||
SemIR::InstId return_slot_arg_id,
|
||||
llvm::ArrayRef<SemIR::InstId> return_arg_ids,
|
||||
bool is_operator_syntax) -> SemIR::InstBlockId {
|
||||
MatchContext match(MatchKind::Caller, specific_id);
|
||||
|
||||
auto return_patterns = context.inst_blocks().GetOrEmpty(return_patterns_id);
|
||||
// Track the return storage, if present.
|
||||
if (return_slot_arg_id.has_value()) {
|
||||
CARBON_CHECK(return_patterns.size() == 1,
|
||||
"TODO: implement support for multiple return patterns");
|
||||
match.AddWork(
|
||||
{.pattern_id = return_patterns[0], .scrutinee_id = return_slot_arg_id});
|
||||
for (auto [return_pattern_id, return_arg_id] :
|
||||
llvm::zip_equal(return_patterns, return_arg_ids)) {
|
||||
if (return_arg_id.has_value()) {
|
||||
match.AddWork(
|
||||
{.pattern_id = return_pattern_id, .scrutinee_id = return_arg_id});
|
||||
} else {
|
||||
CARBON_CHECK(return_arg_ids.size() == 1,
|
||||
"TODO: do the match even if return_arg_id is None, so that "
|
||||
"subsequent args are at the right index in the arg block");
|
||||
}
|
||||
}
|
||||
|
||||
// Check type conversions per-element.
|
||||
|
||||
Reference in New Issue
Block a user