Project

General

Profile

Bug #13717

Calling lambda with keyword arguments inconsistent behavior

Added by hakunin (Michal Hantl) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.5p319 (2016-04-26 revision 54774) [x86_64-darwin16]
[ruby-core:81916]

Description

Context: I am running a callback hook that can have multiple arguments (or none) and multiple keywords (or none).

The idea is to run this and just pass on the params:

hook.call(*args, **kw_args)

But I've encountered an issue which is an inconsistency at the same time:

hook = lambda { |a|
}

hook.call(:a, **{}) # works

kws = {};
hook.call(:a, **kws) # wrong number of arguments (2 for 1)

I would expect the params to just be passed if there are any, or none passed at all, if the object supplied is empty.


Related issues

Is duplicate of Ruby master - Bug #10856: Splat with empty keyword args gives unexpected resultsClosedActions

History

#1

Updated by nobu (Nobuyoshi Nakada) about 2 years ago

  • Is duplicate of Bug #10856: Splat with empty keyword args gives unexpected results added
#2

Updated by nobu (Nobuyoshi Nakada) about 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r59519.


splat keyword hash

  • compile.c (compile_array_keyword_arg): set keyword splat flag if
    explicitly splatted. [ruby-core:68124] [Bug #10856]

  • vm_args.c (setup_parameters_complex): try keyword hash splat if
    given.

Also available in: Atom PDF