Project

General

Profile

Actions

Bug #10856

closed

Splat with empty keyword args gives unexpected results

Added by seantheprogrammer (Sean Griffin) about 9 years ago. Updated about 5 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.2.0p0 (2014-12-25 revision 49005) [x86_64-darwin13]
[ruby-core:68124]

Description

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(*[])

Related issues 7 (0 open7 closed)

Related to Ruby master - Bug #10719: empty splatting literal hash after other keywords causes SEGVClosednobu (Nobuyoshi Nakada)01/09/2015Actions
Related to Ruby master - Bug #13791: `belongs_to': unknown keywords: required, anonymous_class (ArgumentError) since Revision 59519Closednobu (Nobuyoshi Nakada)Actions
Related to Ruby master - Bug #13793: Compatible issue with keyword args behaviorClosedActions
Related to Ruby master - Feature #14183: "Real" keyword argumentClosedActions
Related to Ruby master - Bug #15078: Hash splat of empty hash should not create a positional argument.Closedmatz (Yukihiro Matsumoto)Actions
Has duplicate Ruby master - Misc #11131: Unexpected splatting of empty kwargsClosedActions
Has duplicate Ruby master - Bug #13717: Calling lambda with keyword arguments inconsistent behaviorClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0