From: mame@... Date: 2020-01-10T02:49:01+00:00 Subject: [ruby-core:96752] [Ruby master Bug#16496] Numbered Parameter not parsed properly in lambda Issue #16496 has been updated by mame (Yusuke Endoh). Status changed from Open to Rejected `_1 *1` is parsed as `_1(*1)`, a call to a method `_1` with a variable-length argument with `1`. It is the same as `p * ary` and `p *ary`. You can see a warning under verbose mode: ``` $ ruby -w -e '-> { _1 *1 }.call' -e:1: warning: `*' interpreted as argument prefix ... ``` It is difficult to change until a method name `_1` is valid. ---------------------------------------- Bug #16496: Numbered Parameter not parsed properly in lambda https://bugs.ruby-lang.org/issues/16496#change-83742 * Author: JustinFeng (Justin Feng) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-darwin18] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- 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 `
' 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 `' 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 > ``` -- https://bugs.ruby-lang.org/ Unsubscribe: