[MacRuby] #208: Making #binding public returns wrong binding.
#208: Making #binding public returns wrong binding. -------------------------------------+-------------------------------------- Reporter: eloy.de.enige@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: -------------------------------------+-------------------------------------- Making the binding instance method of a class public does not return the expected binding. Rather it returns the binding from where the caller. Adding a public instance method which returns its private binding works as expected though. So I'm guessing it goes wrong somewhere in the ‘making a method public’ process. Consider: {{{ class Foo def name "foo" end def b binding end end # untitled:13:in `eval': undefined local variable or method `name' for main:NSObject (NameError) # # p eval("name", Foo.new.send(:binding)) # untitled:17:in `eval': undefined local variable or method `name' for main:NSObject (NameError) # # Foo.send(:public, :binding) # p eval("name", Foo.new.binding) # "foo" p eval("name", Foo.new.b) }}} And here you can see that it in fact returns the binding of the caller, not the Foo instance: {{{ lvar = "lvar" Foo.send(:public, :binding) p eval("local_variables", Foo.new.binding) # => [:lvar] }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/208> MacRuby <http://macruby.org/>
#208: Making #binding public returns wrong binding. -------------------------------------+-------------------------------------- Reporter: eloy.de.enige@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.5 Component: MacRuby | Resolution: fixed Keywords: | -------------------------------------+-------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.5 Comment: It looks like this issue is solved in trunk. Note that: 1) doing send(:binding) won't work as expected with 1.9 and will crash for us (assertion). 2) calling #binding on the Foo instance will raise a "private method called" exception on both 1.8 and 1.9. 3) calling #b will work as expected. -- Ticket URL: <http://www.macruby.org/trac/ticket/208#comment:1> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby