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