[#97678] [Ruby master Feature#16752] :private param for const_set — bughitgithub@...
Issue #16752 has been reported by bughit (bug hit).
5 messages
2020/04/02
[ruby-core:97738] [Ruby master Bug#16764] Module.const_source_location does not work on autoloaded constants
From:
sawadatsuyoshi@...
Date:
2020-04-07 04:12:30 UTC
List:
ruby-core #97738
Issue #16764 has been updated by sawa (Tsuyoshi Sawada).
Read the documentation https://ruby-doc.org/core-2.7.0/Module.html#method-i-autoload:
>autoload(module, filename) → nilclick to toggle source
Registers filename to be loaded (using Kernel::require) the first time that module (which may be a String or a symbol) is accessed in the namespace of mod.
Your `foo.rb:1` registers the file to be read when a potential constant named `:Bar` is met. Your `foo.rb:3` calls a constant `Bar` for the first time, at which point the file `./bar` is read and `Bar` is defined.
----------------------------------------
Bug #16764: Module.const_source_location does not work on autoloaded constants
https://bugs.ruby-lang.org/issues/16764#change-84947
* Author: exterm (Philip Müller)
* Status: Open
* Priority: Normal
* ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
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>