Bug #1926

Different eval/binding behaviour in 1.9

Added by Brian Candler over 4 years ago. Updated over 1 year ago.

[ruby-core:24863]
Status:Rejected
Priority:Normal
Assignee:Koichi Sasada
Category:-
Target version:1.9.2
ruby -v:ruby 1.9.2dev (2009-07-18 trunk 24186) [i686-linux] Backport:

Description

=begin
In 1.8.6, you can set a local variable in a binding using eval. This doesn't seem to work in 1.9.2-preview1.

def define_a(b)
eval "a=1", b
end

definea(binding)
puts local
variables.inspect
# 1.8: prints ["a"]
# 1.9: prints []

Similarly:

def another_a(&blk)
eval "a=1", blk.binding
yield
end

anothera do
puts local
variables.inspect
end
# 1.8: prints ["a"]
# 1.9: prints []
=end

History

#1 Updated by Yuki Sonoda over 4 years ago

  • Target version set to 1.9.2

=begin

=end

#2 Updated by Koichi Sasada about 4 years ago

  • Status changed from Open to Rejected
  • Assignee set to Koichi Sasada

=begin
Not a bug. Binding spec is changed from 1.8.
=end

#3 Updated by Steve Shreeve over 1 year ago

Given this change, what is the proper method of setting a local variable in a specific binding?

#4 Updated by Thomas Sawyer over 1 year ago

I guess you don't.

Also available in: Atom PDF