Project

General

Profile

Actions

Bug #13717

closed

Calling lambda with keyword arguments inconsistent behavior

Added by hakunin (Michal Hantl) over 6 years ago. Updated over 6 years ago.

Status:
Closed
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 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #10856: Splat with empty keyword args gives unexpected resultsClosednobu (Nobuyoshi Nakada)Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) over 6 years ago

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

Updated by nobu (Nobuyoshi Nakada) over 6 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0