ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: matz@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:69187] [Ruby trunk - Bug #10856] Splat with empty keyword args gives unexpected results
Date: Thu, 14 May 2015 07:28:33 +0000	[thread overview]
Message-ID: <redmine.journal-52444.20150514072831.90fc5278fd00d162@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-10856.20150215204702@ruby-lang.org

Issue #10856 has been updated by Yukihiro Matsumoto.


It's because ** tries to pass keyword hash (this caes empty) as an argument, so that old style

  def foo(h)
  end
  foo(**{})

to work. In anyway, passing keyword arguments to a method that does not take any keyword argument can cause exception.
If you have real-world use-case, let us know.

Matz.


----------------------------------------
Bug #10856: Splat with empty keyword args gives unexpected results
https://bugs.ruby-lang.org/issues/10856#change-52444

* Author: Sean Griffin
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When keyword args are passed to a method with splat, and there are no keyword args, an empty hash is sent. I would expect no argument to be given, same as splat with an empty array. For example:

    def foo
    end

    foo(**{})

This causes an argument error, as an empty hash is passed. I would expect the same behavior as

    def foo
    end

    foo(*[])



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

  parent reply	other threads:[~2015-05-14  7:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
2015-02-15 20:47 ` [ruby-core:68124] [Ruby trunk - Bug #10856] [Open] Splat with empty keyword args gives unexpected results sean
2015-02-17  5:40 ` [ruby-core:68135] [Ruby trunk - Bug #10856] [Closed] " shugo
2015-03-05 15:31 ` [ruby-core:68429] [Ruby trunk - Bug #10856] " sean
2015-05-11  7:20 ` [ruby-core:69120] [Ruby trunk - Bug #10856] [Open] " nobu
2015-05-14  7:28 ` matz [this message]
2015-08-10 12:27 ` [ruby-core:70299] [Ruby trunk - Bug #10856] " i
2015-08-10 14:33 ` [ruby-core:70302] " ruby-core
2016-08-21  6:09 ` [ruby-core:76995] [Ruby trunk Bug#10856] " guyren
2016-08-21 15:29 ` [ruby-core:76996] " eregontp
2017-07-05 15:21 ` [ruby-core:81918] " nobu
2017-11-01 17:02 ` [ruby-core:83638] [Ruby trunk Bug#10856][Open] " ruby-core
2019-03-14  5:06 ` [ruby-core:91825] [Ruby trunk Bug#10856] " mame
2019-03-14  8:45 ` [ruby-core:91829] " mame

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-52444.20150514072831.90fc5278fd00d162@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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).