You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In jruby lambdas converted to blocks behave differently depending on whether they were created with the lambda or -> syntax.
As expected lambdas enforce arity with both syntaxes when called.
$ jruby -v -e 'def test(l); l.call(1); end; test(lambda{p :ng})'
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.7.051-b13 [darwin-x8664]
ArgumentError: wrong number of arguments (1 for 0)
call at org/jruby/RubyProc.java:267
test at -e:1
(root) at -e:1
$ jruby -v -e 'def test(l); l.call(1); end; test(->(){p :ng})'
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.7.051-b13 [darwin-x8664]
ArgumentError: wrong number of arguments (1 for 0)
call at org/jruby/RubyProc.java:267
test at -e:1
(root) at -e:1
Surprisingly, when converted to a block lambdas behave differently depending on which syntax they were created with. The arity check is gone from those created with lambda
$ jruby -v -e 'def test; yield 1; end; test(&->(){p :ng})'
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.7.051-b13 [darwin-x8664]
ArgumentError: wrong number of arguments (1 for 0)
test at -e:1
(root) at -e:1
$ jruby -v -e 'def test; yield 1; end; test(&lambda{p :ng})'
jruby 1.7.10 (1.9.3p392) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.7.051-b13 [darwin-x8664]
:ng
The text was updated successfully, but these errors were encountered:
I believe this is related to #2164 which has also been resolved as of the latest JRuby 9.0.0.0 release:
➜ sandbox ruby -v -e 'def test; yield 1; end; test(&->(){p :ng})'
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 OpenJDK 64-Bit Server VM 25.45-b02 on 1.8.0_45-internal-b14 +jit [linux-amd64]
ArgumentError: wrong number of arguments (1 for 0)
test at -e:1
<top> at -e:1
➜ sandbox ruby -v -e 'def test; yield 1; end; test(&lambda{p :ng})'
jruby 9.0.0.0 (2.2.2) 2015-07-21 e10ec96 OpenJDK 64-Bit Server VM 25.45-b02 on 1.8.0_45-internal-b14 +jit [linux-amd64]
ArgumentError: wrong number of arguments (1 for 0)
test at -e:1
<top> at -e:1
➜ sandbox
While discussing a weird issue around treating lambdas as blocks in MRI (https://bugs.ruby-lang.org/issues/9605) @nobu found this odd behavior in jruby.
In jruby lambdas converted to blocks behave differently depending on whether they were created with the
lambda
or->
syntax.As expected lambdas enforce arity with both syntaxes when called.
Surprisingly, when converted to a block lambdas behave differently depending on which syntax they were created with. The arity check is gone from those created with
lambda
The text was updated successfully, but these errors were encountered: