mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 06:21:04 +01:00
Fix a crash when checking a nested tuple-pattern (#7716)
Adds a virtual node to `DefaultValuePattern` to end the `ExprRegionForPattern` before checking the expression for the default value. When checking the default value expression, the context was still configured to interpret expressions as patterns, which caused some corruption of state with tuple-pattern subpatterns. Corrects an assertion failure I found while working on feedback from #7665.
This commit is contained in:
@@ -157,6 +157,14 @@ auto HandleParseNode(Context& context, Parse::DefaultValueUnspecifiedId node_id)
|
||||
return context.TODO(node_id, "pattern default values");
|
||||
}
|
||||
|
||||
auto HandleParseNode(Context& context,
|
||||
Parse::DefaultValueExprStartId /*node_id*/) -> bool {
|
||||
// We want to check the default value expression as a normal expression,
|
||||
// and not convert it into a pattern.
|
||||
EndEmptyExprRegionForPattern(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
auto HandleParseNode(Context& context, Parse::DefaultValuePatternId node_id)
|
||||
-> bool {
|
||||
// On entry, the top of the node stack should have an expression for the
|
||||
@@ -205,6 +213,9 @@ auto HandleParseNode(Context& context, Parse::DefaultValuePatternId node_id)
|
||||
.default_value_id = default_value_id});
|
||||
context.node_stack().Push(node_id, default_value_inst_id);
|
||||
|
||||
// We turned off expr region for pattern checking while parsing the default
|
||||
// value expression, so turn it back on again for further pattern checking.
|
||||
BeginExprRegionForPattern(context);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user