Issue #12705 has been updated by Akira Tanaka.


lambda should be strict on number of arguments.
So, stabby lambda (and traditional lambda) should not expand
single array argument.

It works until ruby 2.2.
Ruby 2.2 introduce the bug.

```
% all-ruby -e '
def yield_test
  yield [1, 2]
end
normal_lambda = ->a, b{p [a, b] }
yield_test(&normal_lambda)
'
...
ruby-2.1.10           -e:5:in `block in <main>': wrong number of arguments (1 for 2) (ArgumentError)
                      	from -e:3:in `yield_test'
                      	from -e:6:in `<main>'
                  #<Process::Status: pid 30458 exit 1>
ruby-2.2.0-preview1   [1, 2]
ruby-2.2.0-preview2   [1, 2]
ruby-2.2.0-rc1        [1, 2]
ruby-2.2.0            [1, 2]
ruby-2.2.1            [1, 2]
ruby-2.2.2            [1, 2]
ruby-2.2.3            [1, 2]
ruby-2.2.4            [1, 2]
ruby-2.2.5            [1, 2]
ruby-2.3.0-preview1   [1, 2]
ruby-2.3.0-preview2   [1, 2]
ruby-2.3.0            [1, 2]
ruby-2.3.1            [1, 2]
ruby-2.4.0-preview1   [1, 2]
```


----------------------------------------
Bug #12705: yielding args to a lambda uses block/proc rather than lambda/method semantics
https://bugs.ruby-lang.org/issues/12705#change-60834

* Author: bug hit
* Status: Assigned
* Priority: Normal
* Assignee: Koichi Sasada
* ruby -v: 
* Backport: 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN
----------------------------------------
```ruby
def yield_test
  yield 1, 2
  yield [1, 2]
end

def foo(a, b)
  p a, b
end

method_lambda = method(:foo).to_proc
normal_lambda = ->a, b{p a, b}

yield_test(&normal_lambda)

yield_test(&method_lambda)
```

the yield of [1, 2] to the method_lambda produces an argument error as you would expect
but the same yield to the normal_lamda does not, the single array arg is slpatted per block/proc semantics




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>