Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Binding#dup should actually dup the runtime structures in 1.9 mode #309

Closed
headius opened this Issue Sep 25, 2012 · 2 comments

Comments

Projects
None yet
2 participants
Owner

headius commented Sep 25, 2012

The following code should error out, because the bindings are all being dup'ed before use:

system ~/projects/jruby $ jruby -e "b = binding; eval 'a = 1', b.dup; eval 'p a', b.dup"
1

system ~/projects/jruby $ ruby-1.9.3 -e "b = binding; eval 'a = 1', b.dup; eval 'p a', b.dup"
-e:1:in `<main>': undefined local variable or method `a' for main:Object (NameError)
    from -e:1:in `eval'
    from -e:1:in `<main>'

This is needed for e.g. a more efficient fix for https://bugs.ruby-lang.org/issues/7046

Contributor

MSNexploder commented Jan 2, 2015

Fixed on both - 1.7.18 and master

jruby -v && jruby -e "b = binding; eval 'a = 1', b.dup; eval 'p a', b.dup"
jruby 1.7.18 (1.9.3p551) 2014-12-22 625381c on Java HotSpot(TM) 64-Bit Server VM 1.8.0_25-b17 [darwin-x86_64]
NameError: undefined local variable or method `a' for main:Object
  (root) at -e:1
    eval at org/jruby/RubyKernel.java:1107
  (root) at -e:1

jruby -v && jruby -e "b = binding; eval 'a = 1', b.dup; eval 'p a', b.dup"
jruby 9.0.0.0-SNAPSHOT (2.2.0p0) 2015-01-01 fb9199f Java HotSpot(TM) 64-Bit Server VM 25.25-b02 on 1.8.0_25-b17 +jit [darwin-x86_64]
NameError: undefined local variable or method `a' for main:Object
  (root) at -e:1
    eval at org/jruby/RubyKernel.java:990
  (root) at -e:1
Owner

headius commented Jan 2, 2015

Awesome, thanks for checking and reporting back!

@headius headius closed this Jan 2, 2015

@headius headius added this to the JRuby 1.7.18 milestone Jan 2, 2015

@headius headius self-assigned this Jan 2, 2015

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