summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <[email protected]>2024-08-28 16:56:05 -0400
committergit <[email protected]>2024-08-28 21:10:39 +0000
commitd25833b81a70fae6724d5dc4fe6affb9f2c81690 (patch)
tree821e42b9bc377c1066af78252c556b7062e55b34
parentec88979a06de7320af9eadb2c36c774e4a223f3c (diff)
[ruby/prism] Multi-splat flag for arguments
https://github.com/ruby/prism/commit/21cb9b78ae
-rw-r--r--prism/config.yml2
-rw-r--r--prism/prism.c6
-rw-r--r--test/prism/snapshots/unparser/corpus/literal/send.txt2
3 files changed, 8 insertions, 2 deletions
diff --git a/prism/config.yml b/prism/config.yml
index dc19295c3e..b7c673813b 100644
--- a/prism/config.yml
+++ b/prism/config.yml
@@ -653,6 +653,8 @@ flags:
comment: "if arguments contain keyword splat"
- name: CONTAINS_SPLAT
comment: "if arguments contain splat"
+ - name: CONTAINS_MULTIPLE_SPLATS
+ comment: "if arguments contain multiple splats"
comment: Flags for arguments nodes.
- name: ArrayNodeFlags
values:
diff --git a/prism/prism.c b/prism/prism.c
index 28bd8d0d43..4edb57adc0 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -2065,7 +2065,11 @@ pm_arguments_node_arguments_append(pm_arguments_node_t *node, pm_node_t *argumen
pm_node_list_append(&node->arguments, argument);
if (PM_NODE_TYPE_P(argument, PM_SPLAT_NODE)) {
- pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT);
+ if (PM_NODE_FLAG_P(node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT)) {
+ pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_MULTIPLE_SPLATS);
+ } else {
+ pm_node_flag_set((pm_node_t *) node, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_SPLAT);
+ }
}
}
diff --git a/test/prism/snapshots/unparser/corpus/literal/send.txt b/test/prism/snapshots/unparser/corpus/literal/send.txt
index 9f9eeb13ee..4800b4e2e6 100644
--- a/test/prism/snapshots/unparser/corpus/literal/send.txt
+++ b/test/prism/snapshots/unparser/corpus/literal/send.txt
@@ -1123,7 +1123,7 @@
│ ├── opening_loc: (59,7)-(59,8) = "("
│ ├── arguments:
│ │ @ ArgumentsNode (location: (59,8)-(59,25))
- │ │ ├── flags: contains_splat
+ │ │ ├── flags: contains_splat, contains_multiple_splats
│ │ └── arguments: (length: 3)
│ │ ├── @ SplatNode (location: (59,8)-(59,13))
│ │ │ ├── flags: ∅