ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:67394] [ruby-trunk - Bug #10708] [Open] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
@ 2015-01-07 15:49 ` Damien.Olivier.Robert+ruby
  2015-01-07 20:43 ` [ruby-core:67401] [ruby-trunk - Bug #10708] " sawadatsuyoshi
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: Damien.Olivier.Robert+ruby @ 2015-01-07 15:49 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been reported by Damien Robert.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67401] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
  2015-01-07 15:49 ` [ruby-core:67394] [ruby-trunk - Bug #10708] [Open] In a function call, double splat of an empty hash still calls the function with an argument Damien.Olivier.Robert+ruby
@ 2015-01-07 20:43 ` sawadatsuyoshi
  2015-01-07 21:07 ` [ruby-core:67402] " Damien.Olivier.Robert+ruby
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: sawadatsuyoshi @ 2015-01-07 20:43 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Tsuyoshi Sawada.


Do you mean `**others`?

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50837

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67402] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
  2015-01-07 15:49 ` [ruby-core:67394] [ruby-trunk - Bug #10708] [Open] In a function call, double splat of an empty hash still calls the function with an argument Damien.Olivier.Robert+ruby
  2015-01-07 20:43 ` [ruby-core:67401] [ruby-trunk - Bug #10708] " sawadatsuyoshi
@ 2015-01-07 21:07 ` Damien.Olivier.Robert+ruby
  2015-01-07 21:09 ` [ruby-core:67403] " Damien.Olivier.Robert+ruby
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: Damien.Olivier.Robert+ruby @ 2015-01-07 21:07 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Damien Robert.


Tsuyoshi Sawada wrote:
> Do you mean `**others`?

Yes, sorry for the typo

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50838

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67403] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-01-07 21:07 ` [ruby-core:67402] " Damien.Olivier.Robert+ruby
@ 2015-01-07 21:09 ` Damien.Olivier.Robert+ruby
  2015-01-08 20:21 ` [ruby-core:67438] " dunric29a
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: Damien.Olivier.Robert+ruby @ 2015-01-07 21:09 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Damien Robert.


I think I got bitten by markdown's syntax actually, all my * * got replaced, so s/others/**others/g

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50839

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67438] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-01-07 21:09 ` [ruby-core:67403] " Damien.Olivier.Robert+ruby
@ 2015-01-08 20:21 ` dunric29a
  2015-01-08 21:11 ` [ruby-core:67439] " code
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: dunric29a @ 2015-01-08 20:21 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by David Unric.


By my subjective opinion I don't find this a bug but a feature.

> Consider this:
> def foo; end
> foo(*[]) #Splatting an empty list is ok
> foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

Here you define a method without a (keyword) argument placeholder so it does not expect a Hash argument, which is effectively used to pass keyword arguments at method call, even when keyword arguments are empty. Note calling `foo(kwarg: 'value')` is just a syntactic sugar to `foo({kwarg: 'value'})`.
Methods unlike procs do check arguments count, so ArgumentError exception is the correct behavior.

This is an expected difference to expanding an Array, which results in *plain arguments list* which can result in *"nothing"*, ie. an empty list. `foo(*[])` is interpreted as `foo()` so you won't get an error.

You probably assume expanding a Hash, ie. applying double-splat operator on empty Hash instance at method call would behave the same way. However implementing such a special corner-case behavior would only introduce inconsistency in the language or would require implementing a *quite new different type of plain list* like *"plain keyword arguments list"*.


----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50867

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67439] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2015-01-08 20:21 ` [ruby-core:67438] " dunric29a
@ 2015-01-08 21:11 ` code
  2015-01-09  0:57 ` [ruby-core:67440] " dunric29a
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: code @ 2015-01-08 21:11 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Kolja Kube.


Just to inform everyone, this issue stems from [this post on Stack Overflow](http://stackoverflow.com/questions/27821422/how-can-i-collapse-double-splat-arguments-into-nothing).

Also, I have now idea how the ruby parser works, so if increased parsing complexity is the reason for the discussed behavior, I'm happy to concede my point.

Why I think the current behavior is weird, take these forwarders:

    def call_args(method, *args); send(method, *args); end
    def call_kwargs(method, **opts); send(method, **opts); end

This obviously works:

    def one_arg(arg); end
    def one_kwarg(opt:); end
    
    call_args(:one_arg, 0) # fine
    call_kwargs(:one_kwargs, opt: 0) # also fine

But here the behavior differs:

    def zero_args(); end
    def zero_kwargs(); end
    
    call_args(:zero_args) # fine
    call_kwargs(:zero_kwargs) # error

Now, this is not a problem per se, since the single-splat syntax also permits fowarding keyword arguments. But this simply tripped me up, and since one of Ruby's principles is the principle of least surprise, I look forward to hearing your opinions.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50868

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67440] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2015-01-08 21:11 ` [ruby-core:67439] " code
@ 2015-01-09  0:57 ` dunric29a
  2015-01-09  8:03 ` [ruby-core:67456] [ruby-trunk - Bug #10708] [Assigned] " nobu
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: dunric29a @ 2015-01-09  0:57 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by David Unric.


If I am not mistaken, even latest Ruby 2.2 selects keyword arguments as the last method's argument and of Hash type.

Let's imagine an example where both simple and keyword optional arguments are used:

~~~
def call_multiargs(method, *aopts, **kwopts); send(method, *aopts, **kwopts); end
# kwopts can be passed to send method without double-splat operator as it does _nothing_ here

def args_and_kwargs(*args, **kwargs); p args; p kwargs; end

call_multiargs(:args_and_kwargs, **{a: 1, b:2})
# How should Ruby expand the hash ?
#   - as (:a, 1, :b, 2) list so kwopts would be empty {} ?
#   - as (:a, 1) and {b: 2} so kwopts would be {b: 2} ?
#   - as {a: 1, b:2} so aopts would be empty [] ?
#   - as ([:a, 1], [:b, 2]) list and kwopts would be empty {} ?
#   - as ([:a, 1]) and {:b, 2} ?
#   etc
~~~

Because Ruby has no special keyword list type like Python has and for keyword arguments a single Hash instance is used, it is fundamentally not possible to do an expansion of `**{…}` into a list.
Again, in Ruby there does not exist a list of type `:a => 1, :b => 2`. What you see in a method call is a syntactic sugar for `{:a => 1, :b => 2}`, ie. optional braces.
To keep consistency there can't exist an exception to this rule for empty hashes.

To sum it up, use of double-splat operator for hash expansion is wrong and makes no sense.

p.s. As far as I know, there are only two cases and only as a parser syntax helpers for Hash and Array constructors, quite unrelated to some list expansion:
`{**{:a => 1, :b => 2}}` - enclosed hash items used for implicit form
`[*{:a => 1, :b => 2}]`  - enclosed hash converted with Hash#to_a and used for implicit form


----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50869

* Author: Damien Robert
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:
    def foo; end
    foo(*[]) #Splatting an empty list is ok
    foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error

This is annoying in a function that is a wrapper around another function and just process some keywords:
    def wrapper(*args, keyword: true, **others)
      puts keyword
      wrappee(*args,**others) #here this code will fail if others is empty
    end



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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67456] [ruby-trunk - Bug #10708] [Assigned] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2015-01-09  0:57 ` [ruby-core:67440] " dunric29a
@ 2015-01-09  8:03 ` nobu
  2015-01-12 12:44 ` [ruby-core:67539] [ruby-trunk - Bug #10708] " Damien.Olivier.Robert+ruby
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: nobu @ 2015-01-09  8:03 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Nobuyoshi Nakada.

Description updated
Category set to syntax
Status changed from Open to Assigned
Assignee set to Yukihiro Matsumoto

Although `*args` includes and passes keywords too, but seems you want to add/remove/change some of keyword arguments.
It sounds reasonable to me.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50879

* Author: Damien Robert
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: syntax
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:67539] [ruby-trunk - Bug #10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2015-01-09  8:03 ` [ruby-core:67456] [ruby-trunk - Bug #10708] [Assigned] " nobu
@ 2015-01-12 12:44 ` Damien.Olivier.Robert+ruby
  2016-03-08  2:26 ` [ruby-core:74214] [Ruby trunk Bug#10708] " ozydingo
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: Damien.Olivier.Robert+ruby @ 2015-01-12 12:44 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Damien Robert.


@Kolja: I wasn't aware of your post on stackoverflow when I posted this bug report, but this is indeed a nice coincidence!
For context I sometime want to apply some methods from a module without including the module, so I have a function 'apply' that takes
an unbound method, bind it to an object and send the arguments to this method. Since the object to bind to and the method itself are passed as
keywords to 'apply', I can't use
    method.call(*args,&block)
I need to call
    method.call(*args,**opts,&block)
where I stumbled upon the above bug when opts is empty.

@David: more precisely ruby select keywords as symbols keys of the last argument when it is of Hash type.
When you _call_ a function, using keyword like arguments is a syntaxtic sugar for passing a hash of symbols as the last argument. 
Now consider this:
    amethod({keyword: true})
is the same as
    amethod(keyword: true)
but
    amethod({keyword1: true}, keyword2: true) #one argument and one keyword
is not the same as
    amethod(keyword1: true, keyword2: true) #two keywords
And
    amethod(**{keyword1: true}, keyword2: true) #two keywords
do indeed gives only keywords in ruby already.

So that's why **{} should not be the same as {} but instead expand into 'nothing'.

@Nobuyoshi: thanks for the consideration!

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-50953

* Author: Damien Robert
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:74214] [Ruby trunk Bug#10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2015-01-12 12:44 ` [ruby-core:67539] [ruby-trunk - Bug #10708] " Damien.Olivier.Robert+ruby
@ 2016-03-08  2:26 ` ozydingo
  2016-03-08  4:32 ` [ruby-core:74217] " sawadatsuyoshi
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: ozydingo @ 2016-03-08  2:26 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Andrew Schwartz.


Adding to this, the current behavior results in the following inconsistent behavior: I can call an argless method using a double-splatted empty Hash directly, but this cannot be done via a delegating method. I'm encountering this an an issue with subclasses that override argless parent methods with kwargs, and I would argue that the difference in behavior when calling bar directly vs calling it via foo is very surprising.

~~~ruby
def foo(*args, **kwargs)
  p args
  p kwargs
  bar(*args, **kwargs)
end

def bar
  puts "yay"
end
~~~

~~~
2.2.2 > bar
# => yay
2.2.2 > bar(*[], **{})
yay
2.2.2 > foo
[]
{}
ArgumentError: wrong number of arguments (1 for 0)
    from (irb):13:in `bar'
    from (irb):23:in `foo'
    from (irb):25
~~~

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-57350

* Author: Damien Robert
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:74217] [Ruby trunk Bug#10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2016-03-08  2:26 ` [ruby-core:74214] [Ruby trunk Bug#10708] " ozydingo
@ 2016-03-08  4:32 ` sawadatsuyoshi
  2016-03-08  4:59 ` [ruby-core:74218] " justcolin
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 14+ messages in thread
From: sawadatsuyoshi @ 2016-03-08  4:32 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Tsuyoshi Sawada.


#11860 is a related/duplicate bug.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-57353

* Author: Damien Robert
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:74218] [Ruby trunk Bug#10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2016-03-08  4:32 ` [ruby-core:74217] " sawadatsuyoshi
@ 2016-03-08  4:59 ` justcolin
  2016-05-18  1:07 ` [ruby-core:75588] " shyouhei
  2019-09-02  4:18 ` [ruby-core:94713] [Ruby master " merch-redmine
  13 siblings, 0 replies; 14+ messages in thread
From: justcolin @ 2016-03-08  4:59 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Colin Fulton.


#12022 has some further exploration of this bug.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-57354

* Author: Damien Robert
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:75588] [Ruby trunk Bug#10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2016-03-08  4:59 ` [ruby-core:74218] " justcolin
@ 2016-05-18  1:07 ` shyouhei
  2019-09-02  4:18 ` [ruby-core:94713] [Ruby master " merch-redmine
  13 siblings, 0 replies; 14+ messages in thread
From: shyouhei @ 2016-05-18  1:07 UTC (permalink / raw
  To: ruby-core

Issue #10708 has been updated by Shyouhei Urabe.


Matz is positive about #12157 (removal of optional hash parameters).

If that request is to be accepted,  this double-splat problem should be solved beforehand.  The bug here sources from hash / kwargs confusion so a clear distinction between them is mandatory.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-58722

* Author: Damien Robert
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [ruby-core:94713] [Ruby master Bug#10708] In a function call, double splat of an empty hash still calls the function with an argument
       [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
                   ` (12 preceding siblings ...)
  2016-05-18  1:07 ` [ruby-core:75588] " shyouhei
@ 2019-09-02  4:18 ` merch-redmine
  13 siblings, 0 replies; 14+ messages in thread
From: merch-redmine @ 2019-09-02  4:18 UTC (permalink / raw
  To: ruby-core

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

Status changed from Assigned to Closed

With the acceptance of #14183, double splatting an empty hash when calling a method no longer passes an empty positional hash to the method.

----------------------------------------
Bug #10708: In a function call, double splat of an empty hash still calls the function with an argument
https://bugs.ruby-lang.org/issues/10708#change-81323

* Author: Gondolin (Damien Robert)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
* ruby -v: ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Consider this:

~~~ruby
def foo; end
foo(*[]) #Splatting an empty list is ok
foo(**{}) #Double splatting an empty hash is like calling foo({}) which gives an error
~~~

This is annoying in a function that is a wrapper around another function and just process some keywords:

~~~ruby
def wrapper(*args, keyword: true, **others)
  puts keyword
  wrappee(*args,**others) #here this code will fail if others is empty
end
~~~




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

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2019-09-02  4:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-10708.20150107154912@ruby-lang.org>
2015-01-07 15:49 ` [ruby-core:67394] [ruby-trunk - Bug #10708] [Open] In a function call, double splat of an empty hash still calls the function with an argument Damien.Olivier.Robert+ruby
2015-01-07 20:43 ` [ruby-core:67401] [ruby-trunk - Bug #10708] " sawadatsuyoshi
2015-01-07 21:07 ` [ruby-core:67402] " Damien.Olivier.Robert+ruby
2015-01-07 21:09 ` [ruby-core:67403] " Damien.Olivier.Robert+ruby
2015-01-08 20:21 ` [ruby-core:67438] " dunric29a
2015-01-08 21:11 ` [ruby-core:67439] " code
2015-01-09  0:57 ` [ruby-core:67440] " dunric29a
2015-01-09  8:03 ` [ruby-core:67456] [ruby-trunk - Bug #10708] [Assigned] " nobu
2015-01-12 12:44 ` [ruby-core:67539] [ruby-trunk - Bug #10708] " Damien.Olivier.Robert+ruby
2016-03-08  2:26 ` [ruby-core:74214] [Ruby trunk Bug#10708] " ozydingo
2016-03-08  4:32 ` [ruby-core:74217] " sawadatsuyoshi
2016-03-08  4:59 ` [ruby-core:74218] " justcolin
2016-05-18  1:07 ` [ruby-core:75588] " shyouhei
2019-09-02  4:18 ` [ruby-core:94713] [Ruby master " merch-redmine

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).