Add basic caller-side support for default values in check (#7800)

Modifies the arity check to include a lower-bound for arguments.
Adds logic to pattern matching to supply default arguments for
missing parameters.
This commit is contained in:
Lucile Rose Nihlen
2026-09-22 22:07:35 +00:00
committed by GitHub
parent 795729bb4a
commit 53b7cfbaba
8 changed files with 508 additions and 159 deletions
+3 -2
View File
@@ -2382,9 +2382,10 @@ auto ConvertCallArgs(Context& context, SemIR::InstId self_id,
SemIR::InstId return_arg_id, const SemIR::Function& callee,
SemIR::SpecificId callee_specific_id, bool is_desugared)
-> SemIR::InstBlockId {
// The caller should have ensured this callee has the right arity.
// The caller should have ensured this callee has the right arity, modulo
// default arguments.
CARBON_CHECK(
(self_id.has_value() ? 1 : 0) + arg_refs.size() ==
(self_id.has_value() ? 1 : 0) + arg_refs.size() <=
context.inst_blocks().GetOrEmpty(callee.param_patterns_id).size());
return CallerPatternMatch(context, callee_specific_id, callee.self_param_id,