diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-11-28 15:49:04 -0500 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-11-28 22:33:50 +0000 |
commit | 49383901772f874569bbdc992867bd02b4b597a8 (patch) | |
tree | abd79930a7511b6504a6314f4aab6a0869d86e66 /lib/prism | |
parent | ea3e17e430b74b4e58535a707319025e008cc123 (diff) | |
download | ruby-49383901772f874569bbdc992867bd02b4b597a8.tar.gz |
[ruby/prism] Implicit rest nodes
Fundamentally, `foo { |bar,| }` is different from `foo { |bar, *| }`
because of arity checks. This PR introduces a new node to handle
that, `ImplicitRestNode`, which goes in the `rest` slot of parameter
nodes instead of `RestParameterNode` instances.
This is also used in a couple of other places, namely:
* pattern matching: `foo in [bar,]`
* multi target: `for foo, in bar do end`
* multi write: `foo, = bar`
Now the only splat nodes with a `NULL` value are when you're
forwarding, as in: `def foo(*) = bar(*)`.
https://github.com/ruby/prism/commit/dba2a3b652
Diffstat (limited to 'lib/prism')
-rw-r--r-- | lib/prism/debug.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/prism/debug.rb b/lib/prism/debug.rb index d0469adc9a..adbc402f32 100644 --- a/lib/prism/debug.rb +++ b/lib/prism/debug.rb @@ -121,7 +121,7 @@ module Prism end end, *params.optionals.map(&:name), - *((params.rest.name || :*) if params.rest && params.rest.operator != ","), + *((params.rest.name || :*) if params.rest && !params.rest.is_a?(ImplicitRestNode)), *params.posts.map do |post| if post.is_a?(RequiredParameterNode) post.name |