ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans•net
To: ruby-dev@ruby-lang.org
Subject: [ruby-dev:50844] [Ruby master Bug#11039] method_missing の *args 引数に symbol をキーにした hash だけを渡すと エラーとなる
Date: Mon, 02 Sep 2019 04:27:49 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-81325.20190902042748.1f74adb7d3681d7b@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11039.20150407091139@ruby-lang.org

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/

      parent reply	other threads:[~2019-09-02  4:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11039.20150407091139@ruby-lang.org>
2015-04-07  9:11 ` [ruby-dev:48921] [Ruby trunk - Bug #11039] [Open] method_missing の *args 引数に symbol をキーにした hash だけを渡すと エラーとなる kiyono
2019-09-02  4:27 ` merch-redmine [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-81325.20190902042748.1f74adb7d3681d7b@ruby-lang.org \
    --to=ruby-dev@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).