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 authored and GitHub committed 2026-09-04 01:22:16 +00:00
1 parent 1b969c292b
commit 2952ec9c10
10 files changed
+141 -2

No files matched your search

+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);