Issue #11616 has been updated by Nobuyoshi Nakada.


I think that backtrace cleanup should be removed as well as delegate.rb, [Bug #11461].

----------------------------------------
Bug #11616: Forwardable fails to adjust backtrace when Forwardable is not reachable from the target class
https://bugs.ruby-lang.org/issues/11616#change-54551

* Author: _ wanabe
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-10-24 trunk 52254) [x86_64-darwin15]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
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)
```



-- 
https://bugs.ruby-lang.org/