Treat (pattern) as grouping parens. (#6976)

Do not treat it as a 1-tuple pattern as we used to. The design indicates
that `(pattern)` is invalid, but this appears to be an oversight, and
grouping parens appear to be the intended interpretation.

---------

Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
Richard Smith
2026-03-27 21:13:57 +00:00
committed by GitHub
co-authored by Geoff Romer
parent a2ba7f1262
commit 899e54de36
8 changed files with 178 additions and 22 deletions
+10
View File
@@ -66,6 +66,16 @@ auto HandleParseNode(Context& context, Parse::ExplicitParamListId node_id)
Parse::NodeKind::ExplicitParamListStart);
}
auto HandleParseNode(Context& context, Parse::ParenPatternId node_id) -> bool {
EndSubpatternAsNonExpr(context);
auto pattern_id = context.node_stack().PopPattern();
context.param_and_arg_refs_stack().PopAndDiscard();
context.node_stack()
.PopAndDiscardSoloNodeId<Parse::NodeKind::TuplePatternStart>();
context.node_stack().Push(node_id, pattern_id);
return true;
}
auto HandleParseNode(Context& context, Parse::TuplePatternId node_id) -> bool {
if (context.node_stack().PeekIs(Parse::NodeKind::TuplePatternStart)) {
// End the subpattern started by a trailing comma, or the opening delimiter