ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:68124] [Ruby trunk - Bug #10856] [Open] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
@ 2015-02-15 20:47 ` sean
  2015-02-17  5:40 ` [ruby-core:68135] [Ruby trunk - Bug #10856] [Closed] " shugo
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: sean @ 2015-02-15 20:47 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been reported by Sean Griffin.

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

* 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/

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

* [ruby-core:68135] [Ruby trunk - Bug #10856] [Closed] Splat with empty keyword args gives unexpected results
       [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 ` shugo
  2015-03-05 15:31 ` [ruby-core:68429] [Ruby trunk - Bug #10856] " sean
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: shugo @ 2015-02-17  5:40 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Shugo Maeda.

Status changed from Open to Closed

Sean Griffin wrote:
> 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:

It was fixed in r49193.


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

* Author: Sean Griffin
* Status: Closed
* 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/

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

* [ruby-core:68429] [Ruby trunk - Bug #10856] Splat with empty keyword args gives unexpected results
       [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 ` sean
  2015-05-11  7:20 ` [ruby-core:69120] [Ruby trunk - Bug #10856] [Open] " nobu
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: sean @ 2015-03-05 15:31 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Sean Griffin.


It looks like this bug still exists, and was only fixed when splatting a hash literal. The following code is still broken:

~~~
def foo
end

h = {}
foo(**h)
~~~

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

* Author: Sean Griffin
* Status: Closed
* 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/

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

* [ruby-core:69120] [Ruby trunk - Bug #10856] [Open] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-03-05 15:31 ` [ruby-core:68429] [Ruby trunk - Bug #10856] " sean
@ 2015-05-11  7:20 ` nobu
  2015-05-14  7:28 ` [ruby-core:69187] [Ruby trunk - Bug #10856] " matz
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: nobu @ 2015-05-11  7:20 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Nobuyoshi Nakada.

Status changed from Closed to Open

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

* 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/

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

* [ruby-core:69187] [Ruby trunk - Bug #10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-05-11  7:20 ` [ruby-core:69120] [Ruby trunk - Bug #10856] [Open] " nobu
@ 2015-05-14  7:28 ` matz
  2015-08-10 12:27 ` [ruby-core:70299] " i
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: matz @ 2015-05-14  7:28 UTC (permalink / raw)
  To: ruby-core

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/

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

* [ruby-core:70299] [Ruby trunk - Bug #10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2015-05-14  7:28 ` [ruby-core:69187] [Ruby trunk - Bug #10856] " matz
@ 2015-08-10 12:27 ` i
  2015-08-10 14:33 ` [ruby-core:70302] " ruby-core
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: i @ 2015-08-10 12:27 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Tymon Tobolski.


Hi Matz,

I think I just found a real-world use-case for exactly this issue - please take a look at the (simplified) example below.

~~~ruby
class Dispatcher
  def call(event, args)
    public_send(event, **args)
  end

  def first_event(myarg:)
    # ...
  end

  def second_event
    # ...
  end
end
~~~

And the call site looks like this:

~~~ruby
disp = Dispatcher.new
disp.call(params[:event], params[:args])
~~~


Then we can observe:

~~~ruby
disp.call(:first_event, {myarg: 123}) # => passes correctly, all good               

disp.call(:first_event, {})                         # => missing keyword: myarg - exactly what I'd expect
disp.call(:first_event, {myarg: 123, other: "foo"}) # => unknown keyword: other - exactly what I'd expect      

disp.call(:second_event, {})          # => wrong number of arguments (1 for 0) - this /should/ just pass without error
~~~

So, in case the `params[:args]` is empty we would expect to either get a "missing keyword" exception or simply valid method execution when such param is not required. 

Please let me know what do you think about it.

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

* 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/

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

* [ruby-core:70302] [Ruby trunk - Bug #10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2015-08-10 12:27 ` [ruby-core:70299] " i
@ 2015-08-10 14:33 ` ruby-core
  2016-08-21  6:09 ` [ruby-core:76995] [Ruby trunk Bug#10856] " guyren
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: ruby-core @ 2015-08-10 14:33 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Marc-Andre Lafortune.


I feel this has to be fixed.

foo(**{}) should === foo(**Hash.new) in all cases, and I feel it should not raise an error.

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

* 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/

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

* [ruby-core:76995] [Ruby trunk Bug#10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (6 preceding siblings ...)
  2015-08-10 14:33 ` [ruby-core:70302] " ruby-core
@ 2016-08-21  6:09 ` guyren
  2016-08-21 15:29 ` [ruby-core:76996] " eregontp
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: guyren @ 2016-08-21  6:09 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Guyren Howe.


I believe this behavior is wrong and should be fixed.

This gets in the way of simple functional programming idioms. eg "Call each of these functions with these args until one doesn't fail"

~~~ ruby
class FnSeries
  def initialize(*fns)
    @fns = fns
  end

  def call(*args, **kwargs)
    @fns.each do |fn|
      begin
        return fn.call(*args, **kwargs)
        rescue Exception => e
     end
  end
end
~~~
If one of the fns takes no args, this will fail even if that function would otherwise succeed.

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

* 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/

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

* [ruby-core:76996] [Ruby trunk Bug#10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (7 preceding siblings ...)
  2016-08-21  6:09 ` [ruby-core:76995] [Ruby trunk Bug#10856] " guyren
@ 2016-08-21 15:29 ` eregontp
  2017-07-05 15:21 ` [ruby-core:81918] " nobu
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: eregontp @ 2016-08-21 15:29 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by Benoit Daloze.


Guyren Howe wrote:
> I believe this behavior is wrong and should be fixed.
> 
> This gets in the way of simple functional programming idioms. eg "Call each of these functions with these args until one doesn't fail"

There is a simple fix for your use-case, if you just want to fowrard arguments, don't use ** at all:
(it's not like in Python, keyword arguments are less separated form normal arguments)
 
> ~~~ ruby
> class FnSeries
>   def initialize(*fns)
>     @fns = fns
>   end
> 
>   def call(*args)
>     @fns.each do |fn|
>       begin
>         return fn.call(*args)
>         rescue Exception => e
>      end
>   end
> end
> ~~~

Marc-Andre Lafortune wrote:
> I feel this has to be fixed.
> 
> foo(**{}) should === foo(**Hash.new) in all cases, and I feel it should not raise an error.

I agree, it's highly inconsistent that:

~~~ ruby
def foo(*args); args; end
foo(**{}) # => []
h={}
foo(**h) # => [{}]
foo(h) # => [{}]
~~~

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

* 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/

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

* [ruby-core:81918] [Ruby trunk Bug#10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (8 preceding siblings ...)
  2016-08-21 15:29 ` [ruby-core:76996] " eregontp
@ 2017-07-05 15:21 ` nobu
  2017-11-01 17:02 ` [ruby-core:83638] [Ruby trunk Bug#10856][Open] " ruby-core
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 13+ messages in thread
From: nobu @ 2017-07-05 15:21 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by nobu (Nobuyoshi Nakada).

Description updated

https://github.com/ruby/ruby/compare/trunk...nobu:bug/10856-splat-hash

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

* Author: seantheprogrammer (Sean Griffin)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* 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:

```ruby
def foo
end

foo(**{})
```

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

```ruby
def foo
end

foo(*[])
```



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

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

* [ruby-core:83638] [Ruby trunk Bug#10856][Open] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (9 preceding siblings ...)
  2017-07-05 15:21 ` [ruby-core:81918] " nobu
@ 2017-11-01 17:02 ` ruby-core
  2019-03-14  5:06 ` [ruby-core:91825] [Ruby trunk Bug#10856] " mame
  2019-03-14  8:45 ` [ruby-core:91829] " mame
  12 siblings, 0 replies; 13+ messages in thread
From: ruby-core @ 2017-11-01 17:02 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by marcandre (Marc-Andre Lafortune).

Status changed from Closed to Open
Assignee set to nobu (Nobuyoshi Nakada)
Target version set to 2.5

This is not actually fixed.

```
def foo
  puts "OK"
end

options = {}
foo(**options) # => OK  (In 2.5.0preview1)
args = []
foo(*args, **options) # => ArgumentError: wrong number of arguments (given 1, expected 0)
```

The second call should also output "Ok".

Hopefully Nobu can crack this before 2.5.0

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

* Author: seantheprogrammer (Sean Griffin)
* Status: Open
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 2.5
* 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:

```ruby
def foo
end

foo(**{})
```

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

```ruby
def foo
end

foo(*[])
```



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

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

* [ruby-core:91825] [Ruby trunk Bug#10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (10 preceding siblings ...)
  2017-11-01 17:02 ` [ruby-core:83638] [Ruby trunk Bug#10856][Open] " ruby-core
@ 2019-03-14  5:06 ` mame
  2019-03-14  8:45 ` [ruby-core:91829] " mame
  12 siblings, 0 replies; 13+ messages in thread
From: mame @ 2019-03-14  5:06 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by mame (Yusuke Endoh).

Target version changed from 2.5 to 2.7
Status changed from Closed to Assigned

marcandre (Marc-Andre Lafortune) wrote:
> This is not actually fixed.
> 
> ```
> def foo
>   puts "OK"
> end
> 
> options = {}
> foo(**options) # => OK  (In 2.5.0preview1)
> args = []
> foo(*args, **options) # => ArgumentError: wrong number of arguments (given 1, expected 0)
> ```
> 
> The second call should also output "Ok".
> 
> Hopefully Nobu can crack this before 2.5.0

This is not completely fixed yet:

```
$ ruby -v
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
$ ruby -e 'def foo; end; options = {}; args = []; foo(*args, **options)'
$ ruby -e 'def foo(z); end; options = {}; args = []; foo(*args, 1, **options)'
Traceback (most recent call last):
    1: from -e:1:in `<main>'
-e:1:in `foo': wrong number of arguments (given 2, expected 1) (ArgumentError)
```

I go for the exception.  `opt = {}; foo(**option)` should consistently pass an empty hash instead of ignoring it.  It is not intuitive, but it IS the current spec of keyword argument.  This is a design flaw in the current spec.  I believe that it must be fixed by complete separation between keyword arguments and positional arguments (#14183).

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

* Author: seantheprogrammer (Sean Griffin)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 2.7
* 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:

```ruby
def foo
end

foo(**{})
```

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

```ruby
def foo
end

foo(*[])
```



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

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

* [ruby-core:91829] [Ruby trunk Bug#10856] Splat with empty keyword args gives unexpected results
       [not found] <redmine.issue-10856.20150215204702@ruby-lang.org>
                   ` (11 preceding siblings ...)
  2019-03-14  5:06 ` [ruby-core:91825] [Ruby trunk Bug#10856] " mame
@ 2019-03-14  8:45 ` mame
  12 siblings, 0 replies; 13+ messages in thread
From: mame @ 2019-03-14  8:45 UTC (permalink / raw)
  To: ruby-core

Issue #10856 has been updated by mame (Yusuke Endoh).


Another presentation of the bug:

```
def foo; end
foo(*[], {}) #=> does not raise an exception in 2.6
```

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

* Author: seantheprogrammer (Sean Griffin)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version: 2.7
* 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:

```ruby
def foo
end

foo(**{})
```

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

```ruby
def foo
end

foo(*[])
```



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

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

end of thread, other threads:[~2019-03-14  8:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [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 ` [ruby-core:69187] [Ruby trunk - Bug #10856] " matz
2015-08-10 12:27 ` [ruby-core:70299] " 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

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