ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: justcolin@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:73811] [Ruby trunk Bug#11860] Double splat does not work on empty hash assigned via variable
Date: Sun, 14 Feb 2016 16:48:16 +0000	[thread overview]
Message-ID: <redmine.journal-56989.20160214164814.8169b6ce9216a06f@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11860.20151222083354@ruby-lang.org

Issue #11860 has been updated by Colin Fulton.


A similar bug happens when using the double splat operator in the parameter list of a method definition. See #12022.

----------------------------------------
Bug #11860: Double splat does not work on empty hash assigned via variable
https://bugs.ruby-lang.org/issues/11860#change-56989

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.3.0preview2 (2015-12-11 trunk 53028) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
When an empty hash is given as a literal, the double splat operates on it, and leaves nothing, which is expected.

    class String
      def foo; end
    end

    [**{}] # => []
    "foo".foo(**{}) # => nil
    "foo".send(**{}) # => nil

However, when an empty hash is given via variable, the double splat retains an empty hash in place.

    h = {}

    [**h] # => [{}]
    "foo".foo(**h) # => wrong number of arguments (given 1, expected 0)
    "foo".send(**h) # => wrong number of arguments (given 1, expected 0)



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

  parent reply	other threads:[~2016-02-14 16:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-11860.20151222083354@ruby-lang.org>
2015-12-22  8:33 ` [ruby-core:72429] [Ruby trunk - Bug #11860] [Open] Double splat does not work on empty hash assigned via variable sawadatsuyoshi
2015-12-22  8:35 ` [ruby-core:72430] [Ruby trunk - Bug #11860] " sawadatsuyoshi
2015-12-22 10:59 ` [ruby-core:72431] " sawadatsuyoshi
2016-02-14 16:48 ` justcolin [this message]
2016-03-08  4:32 ` [ruby-core:74216] [Ruby trunk Bug#11860] " sawadatsuyoshi
2016-05-17  8:24 ` [ruby-core:75553] " nobu
2019-09-02 15:28 ` [ruby-core:94746] [Ruby master " merch-redmine

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-56989.20160214164814.8169b6ce9216a06f@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).