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
I found that if I use parens around a set of block parameters, JRuby seems to be re-assigning the existing variable in the containing scope. MRI keeps the block parameter local to the block. This only has been an issue in practice if there is a defined variable with the block param's name, but thought it was worth bringing up.
Here's some minimal example code to show the differences in behavior between JRuby and MRI.
deffoo(key)# no parens around block params{a: "b",c: "d"}.map{ |key,value| [key,value]}returnkeyenddefbar(key)# note the presence of parens around block params{a: "b",c: "d"}.map{ |(key,value)| [key,value]}returnkeyend# Ruby (tested with 1.9.3-p484 and 2.2.0)putsfoo(:hello)# => :helloputsbar(:hello)# => :hello# JRuby (1.7.20)putsfoo(:hello)# => :helloputsbar(:hello)# => :c
The text was updated successfully, but these errors were encountered:
I've committed a fix for 1.7 that we may want to mimic in 9k.
Currently 9k works around bad parser output in IRBuilder by forcing all variables for a multiple assignment to be block-local if they're arguments to the block. The changes I made to 1.7 fixes (or at least improves) the parser output to force the proper scoping of these variables at parse time. I have not ported it forward because of the other workarounds done in IR that would need to be removed or modified.
A followup commit will try and address the depth change hacks in IR
but we still need to create some variables for magic vars in evals
and for flip flop. So unfornately just deleting that fix code in
IR breaks those things. Leaving the IR code does not break our
compat so it more of a maintenance issue...
I found that if I use parens around a set of block parameters, JRuby seems to be re-assigning the existing variable in the containing scope. MRI keeps the block parameter local to the block. This only has been an issue in practice if there is a defined variable with the block param's name, but thought it was worth bringing up.
Here's some minimal example code to show the differences in behavior between JRuby and MRI.
The text was updated successfully, but these errors were encountered: