Support tuple patterns outside parameter lists (#4923)

Parameter lists need substantially different treatment than tuple
patterns in other contexts, so this change splits them into separate
parse node kinds.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Geoff Romer
2025-02-20 03:17:45 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 35f5a7f115
commit 74e1a9949f
201 changed files with 1680 additions and 860 deletions
+8 -8
View File
@@ -98,10 +98,10 @@ TEST_F(TreeTest, PrintPostorderAsYAML) {
ElementsAre(Pair("kind", "FunctionIntroducer"), Pair("text", "fn"))),
Yaml::Mapping(ElementsAre(Pair("kind", "IdentifierNameBeforeParams"),
Pair("text", "F"))),
Yaml::Mapping(
ElementsAre(Pair("kind", "TuplePatternStart"), Pair("text", "("))),
Yaml::Mapping(ElementsAre(Pair("kind", "TuplePattern"), Pair("text", ")"),
Pair("subtree_size", "2"))),
Yaml::Mapping(ElementsAre(Pair("kind", "ExplicitParamListStart"),
Pair("text", "("))),
Yaml::Mapping(ElementsAre(Pair("kind", "ExplicitParamList"),
Pair("text", ")"), Pair("subtree_size", "2"))),
Yaml::Mapping(ElementsAre(Pair("kind", "FunctionDecl"), Pair("text", ";"),
Pair("subtree_size", "5"))),
Yaml::Mapping(ElementsAre(Pair("kind", "FileEnd"), Pair("text", "")))));
@@ -122,8 +122,8 @@ TEST_F(TreeTest, PrintPreorderAsYAML) {
tree_and_subtrees.PrintPreorder(print_stream);
auto param_list = Yaml::Sequence(ElementsAre(Yaml::Mapping(
ElementsAre(Pair("node_index", "3"), Pair("kind", "TuplePatternStart"),
Pair("text", "(")))));
ElementsAre(Pair("node_index", "3"),
Pair("kind", "ExplicitParamListStart"), Pair("text", "(")))));
auto function_decl = Yaml::Sequence(ElementsAre(
Yaml::Mapping(ElementsAre(Pair("node_index", "1"),
@@ -133,8 +133,8 @@ TEST_F(TreeTest, PrintPreorderAsYAML) {
Pair("kind", "IdentifierNameBeforeParams"),
Pair("text", "F"))),
Yaml::Mapping(ElementsAre(Pair("node_index", "4"),
Pair("kind", "TuplePattern"), Pair("text", ")"),
Pair("subtree_size", "2"),
Pair("kind", "ExplicitParamList"),
Pair("text", ")"), Pair("subtree_size", "2"),
Pair("children", param_list)))));
auto file = Yaml::Sequence(ElementsAre(