Project

General

Profile

Bug #13404

Hash#any? yields arguments to lambdas with proc semantics

Added by nelhage (Nelson Elhage) over 2 years ago. Updated about 2 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]
[ruby-core:80580]

Description

l = ->(a, b) { true }

# Raises; Uses Enumerable#all?
{1 => 2}.all?(&l)

# Does not raise; Uses specialized Hash#any?
{1 => 2}.any?(&l)

The Enumerable behavior was changed (correctly) in #12705, but the Hash#any? implementation (introduced in r46866) still allows the lax behavior.


Related issues

Is duplicate of Ruby master - Bug #13391: wrong number of arguments error for Hash#map when lambda givenClosedActions

Associated revisions

Revision 56847290
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 59357,59358: [Backport #13391] [Backport #13404]

    proc.c: rb_block_min_max_arity

    * proc.c (rb_block_min_max_arity): new function to get arity range
      from the current block.
    vm_eval.c: rb_lambda_call

    * enum.c (enum_collect): make the block arity same as the given
      block.  [Bug #13391]

    * internal.h (vm_ifunc): store arity instead of unused id.

    * proc.c (rb_vm_block_min_max_arity): return ifunc arity.

    * vm_eval.c (rb_lambda_call): call method with lambda block.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 59500
Added by nagachika (Tomoyuki Chikanaga) about 2 years ago

merge revision(s) 59357,59358: [Backport #13391] [Backport #13404]

proc.c: rb_block_min_max_arity

* proc.c (rb_block_min_max_arity): new function to get arity range
  from the current block.
vm_eval.c: rb_lambda_call

* enum.c (enum_collect): make the block arity same as the given
  block.  [Bug #13391]

* internal.h (vm_ifunc): store arity instead of unused id.

* proc.c (rb_vm_block_min_max_arity): return ifunc arity.

* vm_eval.c (rb_lambda_call): call method with lambda block.

History

#1

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Is duplicate of Bug #13391: wrong number of arguments error for Hash#map when lambda given added

Updated by hsbt (Hiroshi SHIBATA) about 2 years ago

  • Status changed from Open to Rejected

We continues to discuss #13391

Also available in: Atom PDF