mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user