Project

General

Profile

Bug #16496

Numbered Parameter not parsed properly in lambda

Added by JustinFeng (Justin Feng) 3 months ago. Updated 3 months ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18]
[ruby-core:96750]

Description

The space between * and 1 changes the lambda behaviour, looks like numbered parameter _1 is not parsed properly

2.7.0 :001 > l = -> { _1 * 1 }
2.7.0 :002 > l[2]
 => 2
2.7.0 :003 > l2 = -> { _1 *1 }
2.7.0 :004 > l2[2]
Traceback (most recent call last):
        5: from /Users/justin.feng/.rvm/rubies/ruby-2.7.0/bin/irb:23:in `<main>'
        4: from /Users/justin.feng/.rvm/rubies/ruby-2.7.0/bin/irb:23:in `load'
        3: from /Users/justin.feng/.rvm/rubies/ruby-2.7.0/lib/ruby/gems/2.7.0/gems/irb-1.2.1/exe/irb:11:in `<top (required)>'
        2: from (irb):4
        1: from (irb):3:in `block in irb_binding'
ArgumentError (wrong number of arguments (given 1, expected 0))
2.7.0 :005 >

Also available in: Atom PDF