Project

General

Profile

Actions

Bug #16764

closed

Module.const_source_location does not work on autoloaded constants

Added by exterm (Philip Müller) over 4 years ago. Updated over 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
[ruby-core:97733]

Description

As we found when trying out const_source_location on a Rails project, it breaks when used on autoloaded constants.

Example:

$ cat foo.rb
autoload :Bar, './bar'

Bar

puts Module.const_source_location("Bar")

Returns foo.rb:3, when it should return bar.rb:1.

Actions #1

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Status changed from Open to Closed

Applied in changeset git|927308108cced69cae478798004524b9a5d2f252.


Fix source location of autoloaded constant [Bug #16764]

Updated by nobu (Nobuyoshi Nakada) over 4 years ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN to 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED

Prior to 2.6 don't have Module#const_source_location, but redefinition warning message has this location.

Updated by nagachika (Tomoyuki Chikanaga) over 4 years ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED to 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE

ruby_2_7 c65aae118ccff86096b9983641b371491bc23434 merged revision(s) 927308108cced69cae478798004524b9a5d2f252.

Updated by usa (Usaku NAKAMURA) over 3 years ago

  • Backport changed from 2.5: REQUIRED, 2.6: REQUIRED, 2.7: DONE to 2.5: REQUIRED, 2.6: DONE, 2.7: DONE

bacported into ruby_2_6 at r16764

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0