Actions
Bug #15410
closeddouble-splatted parameters behave differently if one of the keys is an array
Description
➜ 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}, {}]
Actions
Like0
Like0Like0