-
-
Notifications
You must be signed in to change notification settings - Fork 943
Open
Description
Assignments to the implicit it parameter should not reassign the parameter but instead create a new local it variable. JRuby's logic reassigns the implicit.
"foo".tap do
it or flunk
it = it = "bar"
assert_equal([:it], binding.implicit_parameters)
assert_equal("foo", binding.implicit_parameter_get(:it))
assert_equal(true, binding.implicit_parameter_defined?(:it))
assert_equal([:it], binding.local_variables)
assert_equal("bar", binding.local_variable_get(:it))
assert_equal(true, binding.local_variable_defined?(:it))
endIn JRuby, the assert_equal("bar"... fails because there's only one it variable here and it gets reassigned.
We currently allocate variables in the scope by name, so this may require some new representation of implicit variables that does not use the same table. This test (test/mri/ruby/test_proc.rb @ test_implicit_parameters_for_it_complex) will be excluded for now since this is a little bit edge-casey (nobody should be relying on this behavior in code that anyone will ever maintain).
Ref #9061
Reactions are currently unavailable