Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: JRuby 1.6
    • Fix Version/s: JRuby 1.6.1
    • Component/s: Core Classes/Modules
    • Labels:
      None
    • Environment:
      jruby 1.6.0 (ruby-1.9.2-p136) (2011-04-01 b412fce) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java]
    • Number of attachments :
      0

      Description

      % ruby -v -e 'p eval("self", Kernel.binding)'
      ruby 1.9.2p180 (2011-02-18 revision 30907) [i386-darwin9.8.0]
      main

      % rbx -v -e 'p eval("self", Kernel.binding)'
      rubinius 1.2.3dev (1.8.7 381aad7b yyyy-mm-dd JI) [i686-apple-darwin9.8.0]
      main

      % jruby -e 'p eval("self", Kernel.binding)'
      Kernel

      % jruby --1.9 -e 'p eval("self", Kernel.binding)'
      Kernel

        Activity

        Hide
        Charles Oliver Nutter added a comment -

        Did you run into this in real code? I'll look into it.

        Show
        Charles Oliver Nutter added a comment - Did you run into this in real code? I'll look into it.
        Hide
        Charles Oliver Nutter added a comment -

        Hmm, if anything JRuby seems more consistent to me. There must be special-cased behavior for Kernel.binding versus <anything else>.binding.

        ~/projects/jruby &#10132; jruby -e 'p eval("self", Kernel.binding)'
        Kernel
        
        ~/projects/jruby &#10132; jruby -e 'p eval("self", "foo".send(:binding))'
        "foo"
        
        
        Show
        Charles Oliver Nutter added a comment - Hmm, if anything JRuby seems more consistent to me. There must be special-cased behavior for Kernel.binding versus <anything else>.binding. ~/projects/jruby &#10132; jruby -e 'p eval("self", Kernel.binding)' Kernel ~/projects/jruby &#10132; jruby -e 'p eval("self", "foo".send(:binding))' "foo"
        Hide
        Charles Oliver Nutter added a comment -

        We do match 1.8.7:

        ~/projects/jruby &#10132; ruby -v -e 'p eval("self", Kernel.binding)'
        ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
        Kernel
        
        Show
        Charles Oliver Nutter added a comment - We do match 1.8.7: ~/projects/jruby &#10132; ruby -v -e 'p eval("self", Kernel.binding)' ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] Kernel
        Hide
        Charles Oliver Nutter added a comment -

        Ok, full summary. We are matching MRI in 1.8.7 mode, but using the same behavior in 1.9 mode. It appears in 1.9 you can no longer send binding or call binding on Kernel and expect to get the target object as "self".

        ~/projects/jruby &#10132; jruby -e 'p eval("self", Kernel.binding)'
        Kernel
        
        ~/projects/jruby &#10132; jruby --1.9 -e 'p eval("self", Kernel.binding)'
        Kernel
        
        ~/projects/jruby &#10132; ruby -e 'p eval("self", Kernel.binding)'
        Kernel
        
        ~/projects/jruby &#10132; ruby1.9 -e 'p eval("self", Kernel.binding)'
        main
        
        ~/projects/jruby &#10132; jruby -e 'p eval("self", "foo".send(:binding))'
        "foo"
        
        ~/projects/jruby &#10132; jruby --1.9 -e 'p eval("self", "foo".send(:binding))'
        "foo"
        
        ~/projects/jruby &#10132; ruby -e 'p eval("self", "foo".send(:binding))'
        "foo"
        
        ~/projects/jruby &#10132; ruby1.9 -e 'p eval("self", "foo".send(:binding))'
        main
        
        

        So this is really a simple fix...1.9 mode will just not do that anymore.

        Show
        Charles Oliver Nutter added a comment - Ok, full summary. We are matching MRI in 1.8.7 mode, but using the same behavior in 1.9 mode. It appears in 1.9 you can no longer send binding or call binding on Kernel and expect to get the target object as "self". ~/projects/jruby &#10132; jruby -e 'p eval("self", Kernel.binding)' Kernel ~/projects/jruby &#10132; jruby --1.9 -e 'p eval("self", Kernel.binding)' Kernel ~/projects/jruby &#10132; ruby -e 'p eval("self", Kernel.binding)' Kernel ~/projects/jruby &#10132; ruby1.9 -e 'p eval("self", Kernel.binding)' main ~/projects/jruby &#10132; jruby -e 'p eval("self", "foo".send(:binding))' "foo" ~/projects/jruby &#10132; jruby --1.9 -e 'p eval("self", "foo".send(:binding))' "foo" ~/projects/jruby &#10132; ruby -e 'p eval("self", "foo".send(:binding))' "foo" ~/projects/jruby &#10132; ruby1.9 -e 'p eval("self", "foo".send(:binding))' main So this is really a simple fix...1.9 mode will just not do that anymore.
        Hide
        Charles Oliver Nutter added a comment -

        commit 4bd7f026089bb5f2f14f437e8f58cc7224bc8d03
        Author: Charles Oliver Nutter <headius@headius.com>
        Date: Thu Apr 7 17:11:52 2011 -0500

        Fix JRUBY-5680: eval("self", Kernel.binding)

        • 1.9 does not use the target object for binding's self, where 1.8 does.
        Show
        Charles Oliver Nutter added a comment - commit 4bd7f026089bb5f2f14f437e8f58cc7224bc8d03 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Apr 7 17:11:52 2011 -0500 Fix JRUBY-5680 : eval("self", Kernel.binding) 1.9 does not use the target object for binding's self, where 1.8 does.
        Hide
        Charles Oliver Nutter added a comment -

        RubySpec:

        commit 4474de7cab0bb6309e9b59e7973962798810ab57
        Author: Charles Oliver Nutter <headius@headius.com>
        Date:   Thu Apr 7 17:18:05 2011 -0500
        
            Add spec for 'self' in Kernel.binding, which differs between 1.8 and 1.9.
        
        Show
        Charles Oliver Nutter added a comment - RubySpec: commit 4474de7cab0bb6309e9b59e7973962798810ab57 Author: Charles Oliver Nutter <headius@headius.com> Date: Thu Apr 7 17:18:05 2011 -0500 Add spec for 'self' in Kernel.binding, which differs between 1.8 and 1.9.
        Hide
        James M. Lawrence added a comment -

        "Did you run into this in real code?"

        The last three bugs I've filed were found by the live_ast test suite.
        Using eval to implement instance_eval tends to shake out these
        curiosities.

        ::Kernel.binding is useful inside a BasicObject instance (remember
        ::Kernel.instance_method(:binding).bind(self) won't work).

        Note that your fix for this bug (4bd7f02) has unfixed JRUBY-5624,

        % jruby -v --1.9 -e 'Class.new { p eval("self", binding) }'
        jruby 1.6.0 (ruby-1.9.2-p136) (2011-04-08 4bd7f02) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java]
        main
        
        Show
        James M. Lawrence added a comment - "Did you run into this in real code?" The last three bugs I've filed were found by the live_ast test suite. Using eval to implement instance_eval tends to shake out these curiosities. ::Kernel.binding is useful inside a BasicObject instance (remember ::Kernel.instance_method(:binding).bind(self) won't work). Note that your fix for this bug (4bd7f02) has unfixed JRUBY-5624 , % jruby -v --1.9 -e 'Class.new { p eval("self", binding) }' jruby 1.6.0 (ruby-1.9.2-p136) (2011-04-08 4bd7f02) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_24) [darwin-x86_64-java] main
        Hide
        Charles Oliver Nutter added a comment -

        James: Thank you for following up on this. I'll look at that test suite...perhaps it's a good one for us to incorporate into JRuby CI, since it seems to hit all the fun eval edge cases.

        I'll look into 5624 and try to get tests/specs in place to keep both of these working.

        Show
        Charles Oliver Nutter added a comment - James: Thank you for following up on this. I'll look at that test suite...perhaps it's a good one for us to incorporate into JRuby CI, since it seems to hit all the fun eval edge cases. I'll look into 5624 and try to get tests/specs in place to keep both of these working.

          People

          • Assignee:
            Charles Oliver Nutter
            Reporter:
            James M. Lawrence
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: