Skip to content

Commit

Permalink
Constants on keyword rest parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton committed Sep 6, 2023
1 parent d2d4f25 commit 5e1a8fb
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 33 deletions.
6 changes: 4 additions & 2 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1576,10 +1576,12 @@ nodes:
end
- name: KeywordRestParameterNode
fields:
- name: operator_loc
type: location
- name: name
type: constant?
- name: name_loc
type: location?
- name: operator_loc
type: location
comment: |
Represents a keyword rest parameter to a method, block, or lambda definition.
Expand Down
5 changes: 3 additions & 2 deletions src/yarp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3090,8 +3090,9 @@ yp_keyword_rest_parameter_node_create(yp_parser_t *parser, const yp_token_t *ope
.end = (name->type == YP_TOKEN_NOT_PROVIDED ? operator->end : name->end)
},
},
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
.name_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(name)
.name = yp_parser_optional_constant_id_token(parser, name),
.name_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(name),
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator)
};

return node;
Expand Down
10 changes: 5 additions & 5 deletions test/yarp/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ def test_rest_keywords_parameters_before_required_parameters
[],
nil,
[KeywordParameterNode(:b, Location(), nil)],
KeywordRestParameterNode(Location(), Location()),
KeywordRestParameterNode(:rest, Location(), Location()),
nil
),
nil,
Expand Down Expand Up @@ -791,7 +791,7 @@ def test_multiple_error_in_parameters_order
[RequiredParameterNode(:a)],
nil,
[KeywordParameterNode(:b, Location(), nil)],
KeywordRestParameterNode(Location(), Location()),
KeywordRestParameterNode(:args, Location(), Location()),
nil
),
nil,
Expand Down Expand Up @@ -820,7 +820,7 @@ def test_switching_to_optional_arguments_twice
[RequiredParameterNode(:a)],
nil,
[KeywordParameterNode(:b, Location(), nil)],
KeywordRestParameterNode(Location(), Location()),
KeywordRestParameterNode(:args, Location(), Location()),
nil
),
nil,
Expand Down Expand Up @@ -849,7 +849,7 @@ def test_switching_to_named_arguments_twice
[RequiredParameterNode(:a)],
nil,
[KeywordParameterNode(:b, Location(), nil)],
KeywordRestParameterNode(Location(), Location()),
KeywordRestParameterNode(:args, Location(), Location()),
nil
),
nil,
Expand Down Expand Up @@ -1069,7 +1069,7 @@ def test_duplicated_parameter_names
expected = DefNode(
Location(),
nil,
ParametersNode([RequiredParameterNode(:a), RequiredParameterNode(:b)], [], [], nil, [], KeywordRestParameterNode(Location(), Location()), nil),
ParametersNode([RequiredParameterNode(:a), RequiredParameterNode(:b)], [], [], nil, [], KeywordRestParameterNode(:a, Location(), Location()), nil),
nil,
[:a, :b],
Location(),
Expand Down
4 changes: 2 additions & 2 deletions test/yarp/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/yarp/snapshots/non_alphanumeric_methods.txt

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

4 changes: 2 additions & 2 deletions test/yarp/snapshots/procs.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/yarp/snapshots/seattlerb/block_arg_kwsplat.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/yarp/snapshots/seattlerb/block_args_kwargs.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/yarp/snapshots/seattlerb/defn_kwarg_env.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/yarp/snapshots/seattlerb/defn_kwarg_kwsplat.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/yarp/snapshots/seattlerb/defn_kwarg_kwsplat_anon.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/yarp/snapshots/seattlerb/defn_powarg.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/yarp/snapshots/seattlerb/iter_kwarg_kwsplat.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/yarp/snapshots/unparser/corpus/literal/since/32.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/yarp/snapshots/whitequark/args.txt

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

8 changes: 6 additions & 2 deletions test/yarp/snapshots/whitequark/blockargs.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.

2 changes: 1 addition & 1 deletion test/yarp/snapshots/whitequark/forwarded_kwrestarg.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/yarp/snapshots/whitequark/kwrestarg_named.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/yarp/snapshots/whitequark/kwrestarg_unnamed.txt

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

0 comments on commit 5e1a8fb

Please sign in to comment.