Details

    • Type: Bug Bug
    • Status: Resolved Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6.4, JRuby 1.7.0.pre1
    • Fix Version/s: JRuby 1.7.0.pre2
    • Component/s: None
    • Labels:
      None
    • Environment:
      Mac OS X, 64-bit Hotspot server
    • Number of attachments :
      0

      Description

      This rubyspec test fails:

      begin
      eval("a = 2")
      eval("p a")
      rescue Object => e
      puts e.class
      end

      In MRI ruby 1.9.2, you get NameError, in jruby, 2.

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        This is an important one. We should be creating a new scope for every eval. Will fix.

        Show
        Charles Oliver Nutter added a comment - This is an important one. We should be creating a new scope for every eval. Will fix.
        Hide
        Charles Oliver Nutter added a comment -

        Hmm, I'm confused about the sharing. This raises an error in 1.9.3:

        eval 'a = 1'
        eval 'a'
        

        But this does not:

        b = binding
        eval 'a = 1', b
        eval 'a', b
        

        Seems like it's not always a new eval scope, but rather that the eval scope is local to the binding?

        Show
        Charles Oliver Nutter added a comment - Hmm, I'm confused about the sharing. This raises an error in 1.9.3: eval 'a = 1' eval 'a' But this does not: b = binding eval 'a = 1', b eval 'a', b Seems like it's not always a new eval scope, but rather that the eval scope is local to the binding?
        Hide
        Charles Oliver Nutter added a comment -
        commit 0804f539111bf7509115f01fd6840291970eb040
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Wed Aug 1 23:37:32 2012 -0500
        
            Fix JRUBY-6121: Local variables cross eval scopes
            
            In 1.9, eval scopes are local to the binding. Reusing a binding
            reuses the same scope, and passing no binding creates a new one
            each time that needs its own new scope.
        
        :100644 100644 6be59e7... 9565a43... M	spec/tags/1.9/ruby/core/kernel/eval_tags.txt
        :100644 100644 3185eae... 9dc2473... M	src/org/jruby/evaluator/ASTInterpreter.java
        :100644 100644 868e36d... 3815db1... M	src/org/jruby/runtime/Binding.java
        
        Show
        Charles Oliver Nutter added a comment - commit 0804f539111bf7509115f01fd6840291970eb040 Author: Charles Oliver Nutter <headius@headius.com> Date: Wed Aug 1 23:37:32 2012 -0500 Fix JRUBY-6121: Local variables cross eval scopes In 1.9, eval scopes are local to the binding. Reusing a binding reuses the same scope, and passing no binding creates a new one each time that needs its own new scope. :100644 100644 6be59e7... 9565a43... M spec/tags/1.9/ruby/core/kernel/eval_tags.txt :100644 100644 3185eae... 9dc2473... M src/org/jruby/evaluator/ASTInterpreter.java :100644 100644 868e36d... 3815db1... M src/org/jruby/runtime/Binding.java

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            Martin Harriman
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: