Project

General

Profile

Actions

Bug #1926

closed

Different eval/binding behaviour in 1.9

Added by candlerb (Brian Candler) about 15 years ago. Updated almost 12 years ago.

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

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

define_a(binding)
puts local_variables.inspect

1.8: prints ["a"]

1.9: prints []

Similarly:

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

another_a do
puts local_variables.inspect
end

1.8: prints ["a"]

1.9: prints []

=end

Actions #1

Updated by yugui (Yuki Sonoda) about 15 years ago

  • Target version set to 1.9.2

=begin

=end

Actions #2

Updated by ko1 (Koichi Sasada) almost 15 years ago

  • Status changed from Open to Rejected
  • Assignee set to ko1 (Koichi Sasada)

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

Updated by shreeve (Steve Shreeve) about 12 years ago

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

Updated by trans (Thomas Sawyer) almost 12 years ago

I guess you don't.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0