Skip to content

Commit

Permalink
Remove extra locals added by ...
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Nov 10, 2023
1 parent 2bbd359 commit b7850f2
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 37 deletions.
4 changes: 4 additions & 0 deletions lib/prism/debug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ def self.prism_locals(source)
*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
Expand Down
11 changes: 0 additions & 11 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -5569,15 +5569,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.
*/
Expand Down Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions test/prism/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def test_method_parameters_after_arguments_forwarding
nil
),
nil,
[:*, :&, :"...", :a],
[:"...", :a],
Location(),
nil,
Location(),
Expand Down Expand Up @@ -800,7 +800,7 @@ def test_double_arguments_forwarding
nil,
ParametersNode([], [], nil, [], [], ForwardingParameterNode(), nil),
nil,
[:*, :&, :"..."],
[:"..."],
Location(),
nil,
Location(),
Expand Down
8 changes: 4 additions & 4 deletions test/prism/snapshots/methods.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/prism/snapshots/seattlerb/defn_arg_forward_args.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/prism/snapshots/seattlerb/defn_args_forward_args.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/prism/snapshots/seattlerb/defn_forward_args.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/prism/snapshots/whitequark/forward_arg.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions test/prism/snapshots/whitequark/forward_arg_with_open_args.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions test/prism/snapshots/whitequark/forward_args_legacy.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/prism/snapshots/whitequark/trailing_forward_arg.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b7850f2

Please sign in to comment.