Issue #15410 has been updated by duerst (Martin Drst).

Status changed from Open to Closed

Closed at request of original submitter.

----------------------------------------
Bug #15410: double-splatted parameters behave differently if one of the keys is an array
https://bugs.ruby-lang.org/issues/15410#change-75646

* Author: yarmiganosca (Chris Hoffman)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.5.1
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
~~~
 irb
2.5.1 :001 > def thingy(x, **y); [x, y]; end
 => :thingy 
2.5.1 :002 > thingy(4, {:x => 5})
 => [4, {:x=>5}] 
2.5.1 :003 > thingy(4, {[:x] => 5})
Traceback (most recent call last):
       16: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/exe/bundle:22:in `<top (required)>'
       15: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors'
       14: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/exe/bundle:30:in `block in <top (required)>'
       13: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/cli.rb:18:in `start'
       12: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
       11: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/cli.rb:27:in `dispatch'
       10: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
        9: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
        8: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
        7: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/cli.rb:424:in `exec'
        6: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:28:in `run'
        5: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `kernel_load'
        4: from /home/choffman/.rvm/gems/ruby-2.5.1/gems/bundler-1.16.1/lib/bundler/cli/exec.rb:75:in `load'
        3: from /home/choffman/.rvm/rubies/ruby-2.5.1/bin/irb:11:in `<top (required)>'
        2: from (irb):3
        1: from (irb):1:in `thingy'
ArgumentError (wrong number of arguments (given 2, expected 1))
~~~
and
~~~
 irb
2.5.1 :001 > def thingy(x, y = nil, **o); x, y = 4, x if y.nil?; [x, y, o]; end
 => :thingy 
2.5.1 :002 > thingy(5, {:a => 42})
 => [4, 5, {:a=>42}] 
2.5.1 :003 > thingy(5, {[:a] => 42})
 => [5, {[:a]=>42}, {}]
~~~



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>