ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: merch-redmine@jeremyevans.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:94746] [Ruby master Bug#11860] Double splat does not work on empty hash assigned via variable
Date: Mon, 02 Sep 2019 15:28:43 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-81363.20190902152842.0eecc5cc87bd2a71@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-11860.20151222083354@ruby-lang.org

Issue #11860 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

With recent commits to the master branch, keyword splats of empty hashes do not pass positional arguments to methods or cause an empty hash to be added to an array.

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

* Author: sawa (Tsuyoshi Sawada)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* 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.

```ruby
class String
  def foo; end
end

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

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

```ruby
h = {}

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




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

      parent reply	other threads:[~2019-09-02 15:28 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 ` [ruby-core:73811] [Ruby trunk Bug#11860] " justcolin
2016-03-08  4:32 ` [ruby-core:74216] " sawadatsuyoshi
2016-05-17  8:24 ` [ruby-core:75553] " nobu
2019-09-02 15:28 ` 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-81363.20190902152842.0eecc5cc87bd2a71@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).