Refactor AddBindingPattern into composable pieces (#6927)

This is part of some bigger changes in pattern matching, factored out
because it causes some test churn.

Assisted-by: Gemini 3.1 Pro via Antigravity
This commit is contained in:
Geoff Romer
2026-03-19 19:20:03 +00:00
committed by GitHub
parent 10beae2c20
commit 08148f3a3a
137 changed files with 513 additions and 505 deletions
+12 -3
View File
@@ -180,10 +180,19 @@ static auto HandleAnyBindingPattern(Context& context, Parse::NodeId node_id,
auto make_binding_pattern = [&]() -> SemIR::InstId {
// TODO: Eventually the name will need to support associations with other
// scopes, but right now we don't support qualified names here.
auto form_id = pattern_inst_kind == SemIR::FormBindingPattern::Kind
? context.constant_values().Get(type_expr.inst_id)
: SemIR::ConstantId::None;
auto phase = BindingPhase::Runtime;
if (pattern_inst_kind == SemIR::SymbolicBindingPattern::Kind) {
phase = is_template ? BindingPhase::Template : BindingPhase::Symbolic;
}
auto binding = AddBindingPattern(
context, name_node, name_id, type_expr.type_component_id,
context.constant_values().Get(type_expr.inst_id), type_expr_region_id,
pattern_inst_kind, is_template, is_unused);
context, name_node, type_expr_region_id,
{.kind = pattern_inst_kind,
.type_id = GetPatternType(context, type_expr.type_component_id),
.entity_name_id = AddBindingEntityName(context, name_id, form_id,
is_unused, phase)});
// TODO: If `is_generic`, then `binding.bind_id is a SymbolicBinding. Subst
// the `.Self` of type `type` in the `cast_type_id` type (a `FacetType`)