Skip to content

Commit e3f4645

Browse files
haldunmatzbot
authored andcommitted
[ruby/prism] Fix calls with splat without parenthesis
ruby/prism@d81a77e0e3
1 parent 64a122a commit e3f4645

File tree

3 files changed

+75
-30
lines changed

3 files changed

+75
-30
lines changed

prism/prism.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10963,7 +10963,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
1096310963
parser_lex(parser);
1096410964
pm_token_t operator = parser->previous;
1096510965

10966-
if (match2(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA)) {
10966+
if (match3(parser, PM_TOKEN_PARENTHESIS_RIGHT, PM_TOKEN_COMMA, PM_TOKEN_SEMICOLON)) {
1096710967
if (pm_parser_local_depth(parser, &parser->previous) == -1) {
1096810968
pm_parser_err_token(parser, &operator, PM_ERR_ARGUMENT_NO_FORWARDING_STAR);
1096910969
}

test/prism/fixtures/method_calls.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ lst << A {}
145145
"#{ join (" ") }"
146146

147147
"#{(v)}"
148+
149+
def f(*); p *; end

test/prism/snapshots/method_calls.txt

Lines changed: 72 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
@ ProgramNode (location: (1,0)-(147,8))
1+
@ ProgramNode (location: (1,0)-(149,18))
22
├── locals: []
33
└── statements:
4-
@ StatementsNode (location: (1,0)-(147,8))
5-
└── body: (length: 62)
4+
@ StatementsNode (location: (1,0)-(149,18))
5+
└── body: (length: 63)
66
├── @ CallNode (location: (1,0)-(1,14))
77
│ ├── receiver:
88
│ │ @ CallNode (location: (1,0)-(1,3))
@@ -2194,29 +2194,72 @@
21942194
│ │ │ └── name: :join
21952195
│ │ └── closing_loc: (145,15)-(145,16) = "}"
21962196
│ └── closing_loc: (145,16)-(145,17) = "\""
2197-
└── @ InterpolatedStringNode (location: (147,0)-(147,8))
2198-
├── opening_loc: (147,0)-(147,1) = "\""
2199-
├── parts: (length: 1)
2200-
│ └── @ EmbeddedStatementsNode (location: (147,1)-(147,7))
2201-
│ ├── opening_loc: (147,1)-(147,3) = "\#{"
2202-
│ ├── statements:
2203-
│ │ @ StatementsNode (location: (147,3)-(147,6))
2204-
│ │ └── body: (length: 1)
2205-
│ │ └── @ ParenthesesNode (location: (147,3)-(147,6))
2206-
│ │ ├── body:
2207-
│ │ │ @ StatementsNode (location: (147,4)-(147,5))
2208-
│ │ │ └── body: (length: 1)
2209-
│ │ │ └── @ CallNode (location: (147,4)-(147,5))
2210-
│ │ │ ├── receiver: ∅
2211-
│ │ │ ├── call_operator_loc: ∅
2212-
│ │ │ ├── message_loc: (147,4)-(147,5) = "v"
2213-
│ │ │ ├── opening_loc: ∅
2214-
│ │ │ ├── arguments: ∅
2215-
│ │ │ ├── closing_loc: ∅
2216-
│ │ │ ├── block: ∅
2217-
│ │ │ ├── flags: variable_call
2218-
│ │ │ └── name: :v
2219-
│ │ ├── opening_loc: (147,3)-(147,4) = "("
2220-
│ │ └── closing_loc: (147,5)-(147,6) = ")"
2221-
│ └── closing_loc: (147,6)-(147,7) = "}"
2222-
└── closing_loc: (147,7)-(147,8) = "\""
2197+
├── @ InterpolatedStringNode (location: (147,0)-(147,8))
2198+
│ ├── opening_loc: (147,0)-(147,1) = "\""
2199+
│ ├── parts: (length: 1)
2200+
│ │ └── @ EmbeddedStatementsNode (location: (147,1)-(147,7))
2201+
│ │ ├── opening_loc: (147,1)-(147,3) = "\#{"
2202+
│ │ ├── statements:
2203+
│ │ │ @ StatementsNode (location: (147,3)-(147,6))
2204+
│ │ │ └── body: (length: 1)
2205+
│ │ │ └── @ ParenthesesNode (location: (147,3)-(147,6))
2206+
│ │ │ ├── body:
2207+
│ │ │ │ @ StatementsNode (location: (147,4)-(147,5))
2208+
│ │ │ │ └── body: (length: 1)
2209+
│ │ │ │ └── @ CallNode (location: (147,4)-(147,5))
2210+
│ │ │ │ ├── receiver: ∅
2211+
│ │ │ │ ├── call_operator_loc: ∅
2212+
│ │ │ │ ├── message_loc: (147,4)-(147,5) = "v"
2213+
│ │ │ │ ├── opening_loc: ∅
2214+
│ │ │ │ ├── arguments: ∅
2215+
│ │ │ │ ├── closing_loc: ∅
2216+
│ │ │ │ ├── block: ∅
2217+
│ │ │ │ ├── flags: variable_call
2218+
│ │ │ │ └── name: :v
2219+
│ │ │ ├── opening_loc: (147,3)-(147,4) = "("
2220+
│ │ │ └── closing_loc: (147,5)-(147,6) = ")"
2221+
│ │ └── closing_loc: (147,6)-(147,7) = "}"
2222+
│ └── closing_loc: (147,7)-(147,8) = "\""
2223+
└── @ DefNode (location: (149,0)-(149,18))
2224+
├── name: :f
2225+
├── name_loc: (149,4)-(149,5) = "f"
2226+
├── receiver: ∅
2227+
├── parameters:
2228+
│ @ ParametersNode (location: (149,6)-(149,7))
2229+
│ ├── requireds: (length: 0)
2230+
│ ├── optionals: (length: 0)
2231+
│ ├── rest:
2232+
│ │ @ RestParameterNode (location: (149,6)-(149,7))
2233+
│ │ ├── name: ∅
2234+
│ │ ├── name_loc: ∅
2235+
│ │ └── operator_loc: (149,6)-(149,7) = "*"
2236+
│ ├── posts: (length: 0)
2237+
│ ├── keywords: (length: 0)
2238+
│ ├── keyword_rest: ∅
2239+
│ └── block: ∅
2240+
├── body:
2241+
│ @ StatementsNode (location: (149,10)-(149,13))
2242+
│ └── body: (length: 1)
2243+
│ └── @ CallNode (location: (149,10)-(149,13))
2244+
│ ├── receiver: ∅
2245+
│ ├── call_operator_loc: ∅
2246+
│ ├── message_loc: (149,10)-(149,11) = "p"
2247+
│ ├── opening_loc: ∅
2248+
│ ├── arguments:
2249+
│ │ @ ArgumentsNode (location: (149,12)-(149,13))
2250+
│ │ ├── arguments: (length: 1)
2251+
│ │ │ └── @ SplatNode (location: (149,12)-(149,13))
2252+
│ │ │ ├── operator_loc: (149,12)-(149,13) = "*"
2253+
│ │ │ └── expression: ∅
2254+
│ │ └── flags: ∅
2255+
│ ├── closing_loc: ∅
2256+
│ ├── block: ∅
2257+
│ ├── flags: ∅
2258+
│ └── name: :p
2259+
├── locals: [:*]
2260+
├── def_keyword_loc: (149,0)-(149,3) = "def"
2261+
├── operator_loc: ∅
2262+
├── lparen_loc: (149,5)-(149,6) = "("
2263+
├── rparen_loc: (149,7)-(149,8) = ")"
2264+
├── equal_loc: ∅
2265+
└── end_keyword_loc: (149,15)-(149,18) = "end"

0 commit comments

Comments
 (0)