Project

General

Profile

Actions

Feature #18648

closed

ruby2_keywords and ... name arguments with impossible names

Added by aaronjensen (Aaron Jensen) over 2 years ago. Updated over 2 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:107977]

Description

While investigating a break in a library using reflection, I realized that when ... is used or ruby2_keywords is used that Ruby will name arguments with their symbol, rather than leaving them unnamed. This test demonstrates the issue:

https://github.com/ruby/ruby/blob/97426e15d721119738a548ecfa7232b1d027cd34/test/ruby/test_method.rb#L35
https://github.com/ruby/ruby/blob/97426e15d721119738a548ecfa7232b1d027cd34/test/ruby/test_method.rb#L586

I do not understand how :*, :**, and :& are meant to be considered valid parameter names. I assume the reason is so that they do not conflict with something a person could write but that they can still be referenced in Ruby to facilitate delegation but I just wanted to report that it caused a problem downstream.

It's also curious that:

def foo(*, **, &)
end

Gives these parameter: [[:rest], [:keyrest], [:block, :&]]

Why does only block get the faux name? Is it because that's how yield works so there needs to be a way to reference it in Ruby?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0