[ruby/prism] Fix calls with splat without parenthesis

https://github.com/ruby/prism/commit/d81a77e0e3
This commit is contained in:
Haldun Bayhantopcu 2023-11-16 09:55:21 +01:00 committed by git
parent 64a122acfd
commit e3f464522c
3 changed files with 75 additions and 30 deletions

View File

@ -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);
}

View File

@ -145,3 +145,5 @@ lst << A {}
"#{ join (" ") }"
"#{(v)}"
def f(*); p *; end

View File

@ -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"