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:
Lucile Rose Nihlen
2026-09-04 01:22:16 +00:00
committed by GitHub
parent 1b969c292b
commit 2952ec9c10
10 changed files with 141 additions and 2 deletions
+4
View File
@@ -175,6 +175,10 @@ auto HandlePatternListElementCheckForDefaultValue(Context& context) -> void {
return;
}
// Add the first virtual node surrounding the value expr node, to facilitate
// handling in check.
context.AddLeafNode(NodeKind::DefaultValueExprStart, *equals_token);
state.token = *equals_token;
state.kind = StateKind::PatternListElementFinishDefaultValue;
context.PushState(state);