ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:97741] [Ruby master Bug#16764] Module.const_source_location does not work on autoloaded constants
Date: Tue, 07 Apr 2020 15:18:40 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-84950.20200407151839.12256@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16764.20200406200234.12256@ruby-lang.org

Issue #16764 has been updated by nobu (Nobuyoshi Nakada).

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.

----------------------------------------
Bug #16764: Module.const_source_location does not work on autoloaded constants
https://bugs.ruby-lang.org/issues/16764#change-84950

* Author: exterm (Philip Müller)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: REQUIRED, 2.6: REQUIRED, 2.7: REQUIRED
----------------------------------------
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`.



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

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

  parent reply	other threads:[~2020-04-07 15:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-06 20:02 [ruby-core:97733] [Ruby master Bug#16764] Module.const_source_location does not work on autoloaded constants mail
2020-04-07  4:12 ` [ruby-core:97738] " sawadatsuyoshi
2020-04-07 15:18 ` nobu [this message]
2020-07-23  8:47 ` [ruby-core:99296] " nagachika00
2021-04-04 22:42 ` [ruby-core:103214] " usa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-84950.20200407151839.12256@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).