From: merch-redmine@... Date: 2019-09-02T04:27:49+00:00 Subject: [ruby-dev:50844] [Ruby master Bug#11039] method_missing の *args 引数に symbol をキーにした hash だけを渡すと エラーとなる Issue #11039 has been updated by jeremyevans0 (Jeremy Evans). Status changed from Open to Closed With the acceptance of #14183, you now get a warning as the behavior will change in Ruby 3: ```ruby Foo.bar({ b: 1 }) # (irb):67: warning: The last argument is used as the keyword parameter # (irb):58: warning: for `method_missing' defined here # ArgumentError (unknown keyword: :b) ``` In Ruby 3, you will not get a warning, and the hash will be passed as a positional argument. To get the Ruby 3 behavior with the master branch: ```ruby Foo.bar({ b: 1 }, **(;{})) # => [{:b=>1}] ``` ---------------------------------------- Bug #11039: method_missing の *args 引数に symbol をキーにした hash だけを渡すと エラーとなる https://bugs.ruby-lang.org/issues/11039#change-81325 * Author: kiyono (yoshimitsu kiyono) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin13] * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- method_missing に 第3引数として キーワード引数を設定した上で、引数に symbol をキーにした Hash だけを渡すと => unknown keyword: a (ArgumentError) となる。 ※ 第3引数を付け足さなければエラーにならない。 引数が文字列をキーにした Hash であればエラーにならないため、キーが symbol でも Hash であるならば合わせた挙動であるべきではないでしょうか。 ---Files-------------------------------- foo.rb (244 Bytes) -- https://bugs.ruby-lang.org/