summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-11-10 00:09:33 -0500
committergit <svn-admin@ruby-lang.org>2023-11-10 21:50:12 +0000
commit85db7baccb946c6bb463166acdd0fd7b12568d35 (patch)
tree016a1b967c539c0a5ff1ded95cd341c8e3871da3
parent98e5ea94314340c9be37cc490739fd56c772c16b (diff)
[ruby/prism] Remove extra locals added by ...
https://github.com/ruby/prism/commit/b7850f2d30
-rw-r--r--lib/prism/debug.rb4
-rw-r--r--prism/prism.c11
-rw-r--r--test/prism/errors_test.rb4
-rw-r--r--test/prism/snapshots/methods.txt8
-rw-r--r--test/prism/snapshots/seattlerb/defn_arg_forward_args.txt2
-rw-r--r--test/prism/snapshots/seattlerb/defn_args_forward_args.txt2
-rw-r--r--test/prism/snapshots/seattlerb/defn_forward_args.txt2
-rw-r--r--test/prism/snapshots/seattlerb/defn_forward_args__no_parens.txt2
-rw-r--r--test/prism/snapshots/whitequark/endless_method_forwarded_args_legacy.txt2
-rw-r--r--test/prism/snapshots/whitequark/forward_arg.txt2
-rw-r--r--test/prism/snapshots/whitequark/forward_arg_with_open_args.txt20
-rw-r--r--test/prism/snapshots/whitequark/forward_args_legacy.txt6
-rw-r--r--test/prism/snapshots/whitequark/trailing_forward_arg.txt2
13 files changed, 30 insertions, 37 deletions
diff --git a/lib/prism/debug.rb b/lib/prism/debug.rb
index f5d19dc3df..d0469adc9a 100644
--- a/lib/prism/debug.rb
+++ b/lib/prism/debug.rb
@@ -133,6 +133,10 @@ module Prism
*params.keywords.grep(OptionalKeywordParameterNode).map(&:name),
]
+ if params.keyword_rest.is_a?(ForwardingParameterNode)
+ sorted.push(:*, :&, :"...")
+ end
+
sorted << AnonymousLocal if params.keywords.any?
# Recurse down the parameter tree to find any destructured
diff --git a/prism/prism.c b/prism/prism.c
index 845f50f216..cbf0d19356 100644
--- a/prism/prism.c
+++ b/prism/prism.c
@@ -5570,15 +5570,6 @@ pm_parser_local_add(pm_parser_t *parser, pm_constant_id_t constant_id) {
}
/**
- * Add a local variable from a constant string to the current scope.
- */
-static inline void
-pm_parser_local_add_constant(pm_parser_t *parser, const char *start, size_t length) {
- pm_constant_id_t constant_id = pm_parser_constant_id_constant(parser, start, length);
- if (constant_id != 0) pm_parser_local_add(parser, constant_id);
-}
-
-/**
* Add a local variable from a location to the current scope.
*/
static pm_constant_id_t
@@ -11090,8 +11081,6 @@ parse_parameters(
parser_lex(parser);
if (allows_forwarding_parameters) {
- pm_parser_local_add_constant(parser, "*", 1);
- pm_parser_local_add_constant(parser, "&", 1);
pm_parser_local_add_token(parser, &parser->previous);
}
diff --git a/test/prism/errors_test.rb b/test/prism/errors_test.rb
index aeea04d04d..ee4736a000 100644
--- a/test/prism/errors_test.rb
+++ b/test/prism/errors_test.rb
@@ -723,7 +723,7 @@ module Prism
nil
),
nil,
- [:*, :&, :"...", :a],
+ [:"...", :a],
Location(),
nil,
Location(),
@@ -800,7 +800,7 @@ module Prism
nil,
ParametersNode([], [], nil, [], [], ForwardingParameterNode(), nil),
nil,
- [:*, :&, :"..."],
+ [:"..."],
Location(),
nil,
Location(),
diff --git a/test/prism/snapshots/methods.txt b/test/prism/snapshots/methods.txt
index f89ebbd8e0..4bc8fead19 100644
--- a/test/prism/snapshots/methods.txt
+++ b/test/prism/snapshots/methods.txt
@@ -189,7 +189,7 @@
│ │ │ @ ForwardingParameterNode (location: (19,6)-(19,9))
│ │ └── block: ∅
│ ├── body: ∅
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (19,0)-(19,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: (19,5)-(19,6) = "("
@@ -953,7 +953,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :b
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (112,0)-(112,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: (112,5)-(112,6) = "("
@@ -995,7 +995,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :b
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (114,0)-(114,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: (114,5)-(114,6) = "("
@@ -1216,7 +1216,7 @@
│ │ │ │ └── name: :b
│ │ │ └── closing_loc: (136,24)-(136,25) = "}"
│ │ └── closing_loc: (136,25)-(136,26) = "\""
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (136,0)-(136,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: (136,5)-(136,6) = "("
diff --git a/test/prism/snapshots/seattlerb/defn_arg_forward_args.txt b/test/prism/snapshots/seattlerb/defn_arg_forward_args.txt
index cfed07646c..a7fa779738 100644
--- a/test/prism/snapshots/seattlerb/defn_arg_forward_args.txt
+++ b/test/prism/snapshots/seattlerb/defn_arg_forward_args.txt
@@ -39,7 +39,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :b
- ├── locals: [:x, :*, :&, :"..."]
+ ├── locals: [:x, :"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (1,5)-(1,6) = "("
diff --git a/test/prism/snapshots/seattlerb/defn_args_forward_args.txt b/test/prism/snapshots/seattlerb/defn_args_forward_args.txt
index 374ac8adfd..0dff707b29 100644
--- a/test/prism/snapshots/seattlerb/defn_args_forward_args.txt
+++ b/test/prism/snapshots/seattlerb/defn_args_forward_args.txt
@@ -48,7 +48,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :b
- ├── locals: [:x, :y, :z, :*, :&, :"..."]
+ ├── locals: [:x, :y, :z, :"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (1,5)-(1,6) = "("
diff --git a/test/prism/snapshots/seattlerb/defn_forward_args.txt b/test/prism/snapshots/seattlerb/defn_forward_args.txt
index d86e27427a..6f14c0d1b1 100644
--- a/test/prism/snapshots/seattlerb/defn_forward_args.txt
+++ b/test/prism/snapshots/seattlerb/defn_forward_args.txt
@@ -34,7 +34,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :b
- ├── locals: [:*, :&, :"..."]
+ ├── locals: [:"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (1,5)-(1,6) = "("
diff --git a/test/prism/snapshots/seattlerb/defn_forward_args__no_parens.txt b/test/prism/snapshots/seattlerb/defn_forward_args__no_parens.txt
index e0b6844969..de87e9757a 100644
--- a/test/prism/snapshots/seattlerb/defn_forward_args__no_parens.txt
+++ b/test/prism/snapshots/seattlerb/defn_forward_args__no_parens.txt
@@ -34,7 +34,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :m
- ├── locals: [:*, :&, :"..."]
+ ├── locals: [:"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: ∅
diff --git a/test/prism/snapshots/whitequark/endless_method_forwarded_args_legacy.txt b/test/prism/snapshots/whitequark/endless_method_forwarded_args_legacy.txt
index 2c048b39f7..07ff89fe29 100644
--- a/test/prism/snapshots/whitequark/endless_method_forwarded_args_legacy.txt
+++ b/test/prism/snapshots/whitequark/endless_method_forwarded_args_legacy.txt
@@ -34,7 +34,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :bar
- ├── locals: [:*, :&, :"..."]
+ ├── locals: [:"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (1,7)-(1,8) = "("
diff --git a/test/prism/snapshots/whitequark/forward_arg.txt b/test/prism/snapshots/whitequark/forward_arg.txt
index 5c87944e58..1a9aaec90b 100644
--- a/test/prism/snapshots/whitequark/forward_arg.txt
+++ b/test/prism/snapshots/whitequark/forward_arg.txt
@@ -34,7 +34,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :bar
- ├── locals: [:*, :&, :"..."]
+ ├── locals: [:"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (1,7)-(1,8) = "("
diff --git a/test/prism/snapshots/whitequark/forward_arg_with_open_args.txt b/test/prism/snapshots/whitequark/forward_arg_with_open_args.txt
index 4894f7b6cf..7d7727ad27 100644
--- a/test/prism/snapshots/whitequark/forward_arg_with_open_args.txt
+++ b/test/prism/snapshots/whitequark/forward_arg_with_open_args.txt
@@ -38,7 +38,7 @@
│ │ │ ├── block: ∅
│ │ │ ├── flags: ∅
│ │ │ └── name: :bar
- │ │ ├── locals: [:*, :&, :"..."]
+ │ │ ├── locals: [:"..."]
│ │ ├── def_keyword_loc: (1,1)-(1,4) = "def"
│ │ ├── operator_loc: ∅
│ │ ├── lparen_loc: ∅
@@ -82,7 +82,7 @@
│ │ │ ├── block: ∅
│ │ │ ├── flags: ∅
│ │ │ └── name: :bar
- │ │ ├── locals: [:*, :&, :"..."]
+ │ │ ├── locals: [:"..."]
│ │ ├── def_keyword_loc: (5,1)-(5,4) = "def"
│ │ ├── operator_loc: ∅
│ │ ├── lparen_loc: ∅
@@ -106,7 +106,7 @@
│ │ │ @ ForwardingParameterNode (location: (7,8)-(7,11))
│ │ └── block: ∅
│ ├── body: ∅
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (7,0)-(7,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -144,7 +144,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :bar
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (10,0)-(10,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -184,7 +184,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :bar
- │ ├── locals: [:a, :*, :&, :"..."]
+ │ ├── locals: [:a, :"..."]
│ ├── def_keyword_loc: (12,0)-(12,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -224,7 +224,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :bar
- │ ├── locals: [:a, :*, :&, :"..."]
+ │ ├── locals: [:a, :"..."]
│ ├── def_keyword_loc: (16,0)-(16,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -255,7 +255,7 @@
│ │ │ @ ForwardingParameterNode (location: (18,18)-(18,21))
│ │ └── block: ∅
│ ├── body: ∅
- │ ├── locals: [:a, :b, :*, :&, :"..."]
+ │ ├── locals: [:a, :b, :"..."]
│ ├── def_keyword_loc: (18,0)-(18,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -300,7 +300,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :bar
- │ ├── locals: [:b, :*, :&, :"..."]
+ │ ├── locals: [:b, :"..."]
│ ├── def_keyword_loc: (21,0)-(21,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -345,7 +345,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :bar
- │ ├── locals: [:b, :*, :&, :"..."]
+ │ ├── locals: [:b, :"..."]
│ ├── def_keyword_loc: (25,0)-(25,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: ∅
@@ -385,7 +385,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :bar
- ├── locals: [:a, :*, :&, :"..."]
+ ├── locals: [:a, :"..."]
├── def_keyword_loc: (27,0)-(27,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (27,7)-(27,8) = "("
diff --git a/test/prism/snapshots/whitequark/forward_args_legacy.txt b/test/prism/snapshots/whitequark/forward_args_legacy.txt
index e66d785bc1..5bca692fab 100644
--- a/test/prism/snapshots/whitequark/forward_args_legacy.txt
+++ b/test/prism/snapshots/whitequark/forward_args_legacy.txt
@@ -34,7 +34,7 @@
│ │ ├── block: ∅
│ │ ├── flags: ∅
│ │ └── name: :bar
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (1,0)-(1,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: (1,7)-(1,8) = "("
@@ -56,7 +56,7 @@
│ │ │ @ ForwardingParameterNode (location: (3,8)-(3,11))
│ │ └── block: ∅
│ ├── body: ∅
- │ ├── locals: [:*, :&, :"..."]
+ │ ├── locals: [:"..."]
│ ├── def_keyword_loc: (3,0)-(3,3) = "def"
│ ├── operator_loc: ∅
│ ├── lparen_loc: (3,7)-(3,8) = "("
@@ -90,7 +90,7 @@
│ │ └── flags: ∅
│ ├── rparen_loc: (5,23)-(5,24) = ")"
│ └── block: ∅
- ├── locals: [:*, :&, :"..."]
+ ├── locals: [:"..."]
├── def_keyword_loc: (5,0)-(5,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (5,7)-(5,8) = "("
diff --git a/test/prism/snapshots/whitequark/trailing_forward_arg.txt b/test/prism/snapshots/whitequark/trailing_forward_arg.txt
index 450cd0f105..62a884e0e5 100644
--- a/test/prism/snapshots/whitequark/trailing_forward_arg.txt
+++ b/test/prism/snapshots/whitequark/trailing_forward_arg.txt
@@ -43,7 +43,7 @@
│ ├── block: ∅
│ ├── flags: ∅
│ └── name: :bar
- ├── locals: [:a, :b, :*, :&, :"..."]
+ ├── locals: [:a, :b, :"..."]
├── def_keyword_loc: (1,0)-(1,3) = "def"
├── operator_loc: ∅
├── lparen_loc: (1,7)-(1,8) = "("