Actions
Bug #11616
closedForwardable fails to adjust backtrace when Forwardable is not reachable from the target class
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-10-24 trunk 52254) [x86_64-darwin15]
Description
as follows:
$ cat t.rb
require "forwardable"
class Foo < BasicObject
extend ::Forwardable
def_delegator :bar, :baz
end
Foo.new.baz
$ ruby t.rb
/Users/guest/.rbenv/versions/trunk/lib/ruby/2.3.0/forwardable.rb:185:in `rescue in baz': uninitialized constant Foo::Forwardable (NameError)
from /Users/guest/.rbenv/versions/trunk/lib/ruby/2.3.0/forwardable.rb:182:in `baz'
from t.rb:9:in `<main>'
or define Forwardable in the target class:
$ cat t2.rb
require "forwardable"
class Foo
extend Forwardable
def_delegator :bar, :baz
module Forwardable
end
end
Foo.new.baz
$ ruby t2.rb
/Users/guest/.rbenv/versions/trunk/lib/ruby/2.3.0/forwardable.rb:185:in `rescue in baz': undefined method `debug' for Foo::Forwardable:Module (NoMethodError)
from /Users/guest/.rbenv/versions/trunk/lib/ruby/2.3.0/forwardable.rb:182:in `baz'
from t2.rb:12:in `<main>'
expected result:
$ cat t3.rb
require "forwardable"
class Foo
extend ::Forwardable
def_delegator :bar, :baz
end
Foo.new.baz
$ ruby t3.rb
t3.rb:9:in `<main>': undefined local variable or method `bar' for #<Foo:0x007fff0b8db3e8> (NameError)
Updated by nobu (Nobuyoshi Nakada) about 9 years ago
I think that backtrace cleanup should be removed as well as delegate.rb, [Bug #11461].
Updated by nobu (Nobuyoshi Nakada) about 9 years ago
- Status changed from Open to Closed
Applied in changeset r52259.
forwardable.rb: full qualify names
- lib/forwardable.rb (def_instance_delegator, def_single_delegator):
match backtraces against ::Forwardable in case the target class
is a subclass of BasicObject and does not include Kernel.
[ruby-core:71176] [Bug #11616]
Actions
Like0
Like0Like0