[Assigned] Thread::Backtrace::Location#defined_class

Issue #9755 has been reported by Shugo M…


Feature #9755: Thread::Backtrace::Location#defined_class
https://bugs.ruby-lang.org/issues/9755

  • Author: Shugo M.
  • Status: Assigned
  • Priority: Normal
  • Assignee: Koichi Sasada
  • Category: core
  • Target version:

I’d like Thread::Backtrace::Location#defined_class.

class X
  def foo
    p caller_locations.first.defined_class #=> Y
  end
end

class Y
  def bar
    X.new.foo
  end
end

Y.new.bar

nobu created a patch:

https://github.com/nobu/ruby/compare/backtrace-self%2Bclass

But this patch has two problems:

  1. The patch adds Thread::Backtrace::Location#self, but it’s weird that
    a location has self.
  2. Thread::Backtrace::Location#class conflicts with Kernel#class.
    So I proposed defined_class as the method name.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs