Project

General

Profile

Bug #11616

Forwardable fails to adjust backtrace when Forwardable is not reachable from the target class

Added by wanabe (_ wanabe) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-10-24 trunk 52254) [x86_64-darwin15]
[ruby-core:71176]

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)

Associated revisions

Revision 4e1ee809
Added by nobu (Nobuyoshi Nakada) about 4 years ago

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 52259
Added by nobu (Nobuyoshi Nakada) about 4 years ago

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]

Revision 52259
Added by nobu (Nobuyoshi Nakada) about 4 years ago

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]

Revision 52259
Added by nobu (Nobuyoshi Nakada) about 4 years ago

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]

Revision 52259
Added by nobu (Nobuyoshi Nakada) about 4 years ago

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]

Revision 52259
Added by nobu (Nobuyoshi Nakada) about 4 years ago

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]

History

Updated by nobu (Nobuyoshi Nakada) about 4 years ago

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

#2

Updated by nobu (Nobuyoshi Nakada) about 4 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]

Also available in: Atom PDF