Allocate CallParamIndexes eagerly (#6540)

This approach is more robust because there's no intermediate state where
the `ParamPattern` insts have been created, but don't yet have their
final values.
This commit is contained in:
Geoff Romer
2026-01-05 19:38:52 +00:00
committed by GitHub
parent 08051393dc
commit b72bfb918b
10 changed files with 41 additions and 38 deletions
+6 -5
View File
@@ -156,11 +156,12 @@ auto AddParamPattern(Context& context, SemIR::LocId loc_id,
pattern_id = AddPatternInst(
context,
SemIR::LocIdAndInst::UncheckedLoc(
loc_id, SemIR::AnyParamPattern{
.kind = param_pattern_kind,
.type_id = context.insts().Get(pattern_id).type_id(),
.subpattern_id = pattern_id,
.index = SemIR::CallParamIndex::None}));
loc_id,
SemIR::AnyParamPattern{
.kind = param_pattern_kind,
.type_id = context.insts().Get(pattern_id).type_id(),
.subpattern_id = pattern_id,
.index = context.full_pattern_stack().NextCallParamIndex()}));
return pattern_id;
}