Skip to content

Commit

Permalink
[ruby/prism] Fix to parse command-style method calls more correctly
Browse files Browse the repository at this point in the history
Fix ruby/prism#1468
Fix ruby/prism#1575

To decide command-style method calls are allowed, this introduce a new
parameter `accepts_command_call` to `parse_expression` and some
functions.

Although one think this can be solved by operator precedence, it is
hard or impossible, because the precedence of command-style calls is skewed
(e.g. `! bar 1 ` is accepted, but `foo = ! bar 1` is rejected.)

One of the most complex examples is that:
(1) even though `foo = bar = baz 1` and `foo, bar = baz 1` is accepted,
(2) `foo, bar = baz = fuzz 1` is rejected.
To implement this behavior, this introduces a new binding power
`PM_BINDING_POWER_MULTI_ASSIGNMENT` and uses it for distinguish which single
assignments or multi assignments at their RHS.

ruby/prism@d4dd49ca81
  • Loading branch information
makenowjust authored and matzbot committed Dec 5, 2023
1 parent 6b9622e commit dcd75fd
Show file tree
Hide file tree
Showing 4 changed files with 781 additions and 156 deletions.

0 comments on commit dcd75fd

Please sign in to comment.