[MacRuby-devel] [MacRuby] #208: Making #binding public returns wrong binding.
MacRuby
ruby-noreply at macosforge.org
Fri Jan 16 02:59:16 PST 2009
#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/>
More information about the MacRuby-devel
mailing list