Project

General

Profile

Bug #14639

Array#map and lambda arity regression

Added by lenwood (Paul Martensen) 11 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:86362]

Description

From ruby 2.4.1 onward the following script breaks (ArgumentError):

print_three = ->(a, b, c) { puts [a, b, c] }
arr = [[1, 2, 3]]

arr.map(&print_three)

This now requires explicit destructuring:

print_three = ->((a, b, c)) { puts [a, b, c] }

I guess this comes from a change in enum.c (line 45) from #9605 which seems to be similar.

While digging around I found https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/48193/diff that seems to address this very issue but I'm not sure.

If this is expected behavior feel free to disregard this.

First time posting to ruby trunk so I'm sorry If there is any Information missing.


Related issues

Related to Ruby trunk - Bug #15285: lambda return behavior regression from #14639ClosedActions

Associated revisions

Revision e42f4ae7
Added by nobu (Nobuyoshi Nakada) 11 months ago

array.c: yield blockarg in collect

  • array.c (rb_ary_collect): yield in block argument semantics always to splat array elements to lambda, for the backward compatibility. [ruby-core:86362] [Bug #14639]

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

Revision 63030
Added by nobu (Nobuyoshi Nakada) 11 months ago

array.c: yield blockarg in collect

  • array.c (rb_ary_collect): yield in block argument semantics always to splat array elements to lambda, for the backward compatibility. [ruby-core:86362] [Bug #14639]

Revision 63030
Added by nobu (Nobuyoshi Nakada) 11 months ago

array.c: yield blockarg in collect

  • array.c (rb_ary_collect): yield in block argument semantics always to splat array elements to lambda, for the backward compatibility. [ruby-core:86362] [Bug #14639]

Revision ea15cedd
Added by nagachika (Tomoyuki Chikanaga) 4 months ago

merge revision(s) 63030: [Backport #14639]

    array.c: yield blockarg in collect

    * array.c (rb_ary_collect): yield in block argument semantics
      always to splat array elements to lambda, for the backward
      compatibility.  [ruby-core:86362] [Bug #14639]

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

Revision 64996
Added by nagachika (Tomoyuki Chikanaga) 4 months ago

merge revision(s) 63030: [Backport #14639]

array.c: yield blockarg in collect

* array.c (rb_ary_collect): yield in block argument semantics
  always to splat array elements to lambda, for the backward
  compatibility.  [ruby-core:86362] [Bug #14639]

History

#1

Updated by marcandre (Marc-Andre Lafortune) 11 months ago

  • Subject changed from No #to_ary destructuring when mapping with lambda to Array#map and lambda arity change

Updated by marcandre (Marc-Andre Lafortune) 11 months ago

  • Subject changed from Array#map and lambda arity change to Array#map and lambda arity regression

Good checking.

Indeed, #9605 introduced lambda arity relaxation and this announced in the 2.2 NEWS.

Looks like a regression was introduced by #12705?

#3

Updated by nobu (Nobuyoshi Nakada) 11 months ago

  • Status changed from Open to Closed

Applied in changeset trunk|r63030.


array.c: yield blockarg in collect

  • array.c (rb_ary_collect): yield in block argument semantics always to splat array elements to lambda, for the backward compatibility. [ruby-core:86362] [Bug #14639]
#4

Updated by nobu (Nobuyoshi Nakada) 11 months ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: REQUIRED, 2.5: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) 4 months ago

  • Backport changed from 2.3: DONTNEED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: REQUIRED, 2.5: DONE

ruby_2_5 r64996 merged revision(s) 63030.

#7

Updated by shyouhei (Shyouhei Urabe) 3 months ago

  • Related to Bug #15285: lambda return behavior regression from #14639 added

Also available in: Atom PDF