Restructure handling of expressions in patterns (#7445)

Instead of maintaining a stack of pending subpatterns which might or
might not contain expressions, we mark non-nesting regions during
pattern handling that might contain an expression. The implementation
remains largely the same; the difference is that callers are expected to
end a pending expression region as soon as possible, rather than wait
for the end of the subpattern. This makes it possible to emit
non-pattern insts during pattern handling, without the risk that they
will get caught in a pending expression region further up the stack.
This commit is contained in:
Geoff Romer
2026-07-01 19:15:34 +00:00
committed by GitHub
parent e7771c2f6d
commit 11eaeeda7d
10 changed files with 99 additions and 71 deletions
+3 -1
View File
@@ -531,7 +531,9 @@ auto MatchContext::DoPreWork(State state, SemIR::AnyParamPattern param_pattern,
.work = PreWork{.scrutinee_id = param_id},
.allow_unmarked_ref = entry.allow_unmarked_ref});
} else {
results_stack_.AppendToTop(param_id);
if (need_subpattern_results()) {
results_stack_.AppendToTop(param_id);
}
}
callee_state->PushCallParamPattern(context_, loc_id, entry.pattern_id,