-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lambda with arity -2 can be called with three arguments in 9K #2441
Comments
I have to ask...how does this affect you? |
It's mostly an inconsistency that I accidentally caught when a test started failing. It's a test for a piece of code that tries to figure out how many arguments it can pass to a listener (which can be a block, a lambda, a method, or anything callable). When the arity is -2 it can't really know how many are ok to pass so it just tries to call the method. In 9K the listener is called, but in previous versions of JRuby and in MRI there's an If I could choose I'd like all Rubies to work like 9K, but I thought I'd report it since it's an inconsistency with MRI. |
The reason why I'm doing the arity checking at all is for backwards compatibility. A previous version called the listeners with other arguments. |
I would like to see this solved before we entertain call protocol changes in IR for blocks which will not happen for 9k.0 but still we should fully nail all semantics of blocks down before trying to tackle it. |
My concern with this is that lambdas have always raised arity errors, and if they aren't now we've got a significant behavioral difference. It's a difference most people won't see, but I don't like it anyway. |
This code fails with
ArgumentError
in MRI (at least since 1.9.3) and JRuby 1.7, but not in JRuby 9K:In JRuby 9K (and MRI 1.8.7 I believe) the block is run with 1 and 2 as the values of
a
andb
, the 3 is discarded.The text was updated successfully, but these errors were encountered: