Variables scope problem #2131

Closed
pyromaniac opened this Issue Jan 22, 2013 · 2 comments

Comments

Projects
None yet
3 participants

Hi guys!
At first, thank you for your work.
At last - I've found interesting workaround, looks like a bug:

rubinius-2.0.0.rc1 :005 > {:param=>"'hello'"}.each_with_object({}) { |(key, value), result| p key; p value; p result }
:param
"'hello'"
{}
 => {} 
rubinius-2.0.0.rc1 :006 > key = 'hahaa'
 => "hahaa" 
rubinius-2.0.0.rc1 :007 > {:param=>"'hello'"}.each_with_object({}) { |(key, value), result| p key; p value; p result }
"hahaa"
nil
[:param, "'hello'"]

As you can see, outer scope affects inner.

rbx -v
rubinius 2.0.0.rc1 (1.9.3 release yyyy-mm-dd JI) [x86_64-apple-darwin12.2.1]

Member

solson commented Feb 19, 2013

Note that this bug only affects Ruby 1.9 mode. Here's a smaller test case:

>> lambda{|(a,b)| [a, b] }.call([1,2])
=> [1, 2]
>> a = :test
=> :test
>> lambda{|(a,b)| [a, b] }.call([1,2])
=> [:test, nil]

In MRI, the lambda call returns [1, 2] in both cases.

I'd love to see this fixed. It caused some rather confusing problems in my code.

Owner

dbussink commented Apr 12, 2013

This was fixed with 91d01a6

dbussink closed this Apr 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment