mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 17:15:49 +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:
@@ -167,7 +167,7 @@ static auto HandleAnyBindingPattern(
|
||||
self_type_inst_id);
|
||||
|
||||
SemIR::ExprRegionId type_expr_region_id =
|
||||
ConsumeSubpatternExpr(context, type_expr.inst_id);
|
||||
ConsumeExprRegionForPattern(context, type_expr.inst_id);
|
||||
|
||||
// The name in a generic binding may be wrapped in `template`.
|
||||
bool is_generic = node_kind == Parse::NodeKind::CompileTimeBindingPattern;
|
||||
@@ -502,7 +502,7 @@ auto HandleParseNode(Context& context,
|
||||
auto [cast_type_inst_id, cast_type_id] =
|
||||
ExprAsType(context, type_node, parsed_type_id);
|
||||
|
||||
auto region_id = ConsumeSubpatternExpr(context, cast_type_inst_id);
|
||||
auto region_id = ConsumeExprRegionForPattern(context, cast_type_inst_id);
|
||||
// TODO: Should we be tracking this somewhere?
|
||||
(void)region_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user