diff options
author | Haldun Bayhantopcu <haldun@github.com> | 2023-11-16 09:55:21 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-16 15:13:08 +0000 |
commit | e3f464522ca3d1d742a7bba7cb3ad132997a050f (patch) | |
tree | aae2068a42031d2ffcd6690337854a8f3c653d58 | |
parent | 64a122acfdd93d498a79a50c6ddf1887f253a952 (diff) |
[ruby/prism] Fix calls with splat without parenthesis
https://github.com/ruby/prism/commit/d81a77e0e3
-rw-r--r-- | prism/prism.c | 2 | ||||
-rw-r--r-- | test/prism/fixtures/method_calls.txt | 2 | ||||
-rw-r--r-- | test/prism/snapshots/method_calls.txt | 101 |
3 files changed, 75 insertions, 30 deletions
diff --git a/prism/prism.c b/prism/prism.c index 17051e23fe..eb6e6dabeb 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -10963,7 +10963,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for parser_lex(parser); pm_token_t operator = parser->previous; - if (match2(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA)) { + if (match3(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA, PM_TOKEN_SEMICOLON)) { if (pm_parser_local_depth(parser, &parser->previous) == -1) { pm_parser_err_token(parser, &operator, PM_ERR_ARGUMENT_NO_FORWARDING_STAR); } diff --git a/test/prism/fixtures/method_calls.txt b/test/prism/fixtures/method_calls.txt index 5d82abef2e..d8c32a148f 100644 --- a/test/prism/fixtures/method_calls.txt +++ b/test/prism/fixtures/method_calls.txt @@ -145,3 +145,5 @@ lst << A {} "#{ join (" ") }" "#{(v)}" + +def f(*); p *; end diff --git a/test/prism/snapshots/method_calls.txt b/test/prism/snapshots/method_calls.txt index 0f77a9f88d..6b339f5151 100644 --- a/test/prism/snapshots/method_calls.txt +++ b/test/prism/snapshots/method_calls.txt @@ -1,8 +1,8 @@ -@ ProgramNode (location: (1,0)-(147,8)) +@ ProgramNode (location: (1,0)-(149,18)) ├── locals: [] └── statements: - @ StatementsNode (location: (1,0)-(147,8)) - └── body: (length: 62) + @ StatementsNode (location: (1,0)-(149,18)) + └── body: (length: 63) ├── @ CallNode (location: (1,0)-(1,14)) │ ├── receiver: │ │ @ CallNode (location: (1,0)-(1,3)) @@ -2194,29 +2194,72 @@ │ │ │ └── name: :join │ │ └── closing_loc: (145,15)-(145,16) = "}" │ └── closing_loc: (145,16)-(145,17) = "\"" - └── @ InterpolatedStringNode (location: (147,0)-(147,8)) - ├── opening_loc: (147,0)-(147,1) = "\"" - ├── parts: (length: 1) - │ └── @ EmbeddedStatementsNode (location: (147,1)-(147,7)) - │ ├── opening_loc: (147,1)-(147,3) = "\#{" - │ ├── statements: - │ │ @ StatementsNode (location: (147,3)-(147,6)) - │ │ └── body: (length: 1) - │ │ └── @ ParenthesesNode (location: (147,3)-(147,6)) - │ │ ├── body: - │ │ │ @ StatementsNode (location: (147,4)-(147,5)) - │ │ │ └── body: (length: 1) - │ │ │ └── @ CallNode (location: (147,4)-(147,5)) - │ │ │ ├── receiver: ∅ - │ │ │ ├── call_operator_loc: ∅ - │ │ │ ├── message_loc: (147,4)-(147,5) = "v" - │ │ │ ├── opening_loc: ∅ - │ │ │ ├── arguments: ∅ - │ │ │ ├── closing_loc: ∅ - │ │ │ ├── block: ∅ - │ │ │ ├── flags: variable_call - │ │ │ └── name: :v - │ │ ├── opening_loc: (147,3)-(147,4) = "(" - │ │ └── closing_loc: (147,5)-(147,6) = ")" - │ └── closing_loc: (147,6)-(147,7) = "}" - └── closing_loc: (147,7)-(147,8) = "\"" + ├── @ InterpolatedStringNode (location: (147,0)-(147,8)) + │ ├── opening_loc: (147,0)-(147,1) = "\"" + │ ├── parts: (length: 1) + │ │ └── @ EmbeddedStatementsNode (location: (147,1)-(147,7)) + │ │ ├── opening_loc: (147,1)-(147,3) = "\#{" + │ │ ├── statements: + │ │ │ @ StatementsNode (location: (147,3)-(147,6)) + │ │ │ └── body: (length: 1) + │ │ │ └── @ ParenthesesNode (location: (147,3)-(147,6)) + │ │ │ ├── body: + │ │ │ │ @ StatementsNode (location: (147,4)-(147,5)) + │ │ │ │ └── body: (length: 1) + │ │ │ │ └── @ CallNode (location: (147,4)-(147,5)) + │ │ │ │ ├── receiver: ∅ + │ │ │ │ ├── call_operator_loc: ∅ + │ │ │ │ ├── message_loc: (147,4)-(147,5) = "v" + │ │ │ │ ├── opening_loc: ∅ + │ │ │ │ ├── arguments: ∅ + │ │ │ │ ├── closing_loc: ∅ + │ │ │ │ ├── block: ∅ + │ │ │ │ ├── flags: variable_call + │ │ │ │ └── name: :v + │ │ │ ├── opening_loc: (147,3)-(147,4) = "(" + │ │ │ └── closing_loc: (147,5)-(147,6) = ")" + │ │ └── closing_loc: (147,6)-(147,7) = "}" + │ └── closing_loc: (147,7)-(147,8) = "\"" + └── @ DefNode (location: (149,0)-(149,18)) + ├── name: :f + ├── name_loc: (149,4)-(149,5) = "f" + ├── receiver: ∅ + ├── parameters: + │ @ ParametersNode (location: (149,6)-(149,7)) + │ ├── requireds: (length: 0) + │ ├── optionals: (length: 0) + │ ├── rest: + │ │ @ RestParameterNode (location: (149,6)-(149,7)) + │ │ ├── name: ∅ + │ │ ├── name_loc: ∅ + │ │ └── operator_loc: (149,6)-(149,7) = "*" + │ ├── posts: (length: 0) + │ ├── keywords: (length: 0) + │ ├── keyword_rest: ∅ + │ └── block: ∅ + ├── body: + │ @ StatementsNode (location: (149,10)-(149,13)) + │ └── body: (length: 1) + │ └── @ CallNode (location: (149,10)-(149,13)) + │ ├── receiver: ∅ + │ ├── call_operator_loc: ∅ + │ ├── message_loc: (149,10)-(149,11) = "p" + │ ├── opening_loc: ∅ + │ ├── arguments: + │ │ @ ArgumentsNode (location: (149,12)-(149,13)) + │ │ ├── arguments: (length: 1) + │ │ │ └── @ SplatNode (location: (149,12)-(149,13)) + │ │ │ ├── operator_loc: (149,12)-(149,13) = "*" + │ │ │ └── expression: ∅ + │ │ └── flags: ∅ + │ ├── closing_loc: ∅ + │ ├── block: ∅ + │ ├── flags: ∅ + │ └── name: :p + ├── locals: [:*] + ├── def_keyword_loc: (149,0)-(149,3) = "def" + ├── operator_loc: ∅ + ├── lparen_loc: (149,5)-(149,6) = "(" + ├── rparen_loc: (149,7)-(149,8) = ")" + ├── equal_loc: ∅ + └── end_keyword_loc: (149,15)-(149,18) = "end" |