* [ruby-core:68831] [Ruby trunk - Bug #11055] [Assigned] autoload resets private_constant
[not found] <redmine.issue-11055.20150410083633@ruby-lang.org>
@ 2015-04-10 8:36 ` nobu
2019-08-12 4:02 ` [ruby-core:94299] [Ruby master Bug#11055] " merch-redmine
2019-10-17 5:21 ` [ruby-core:95379] " matz
2 siblings, 0 replies; 3+ messages in thread
From: nobu @ 2015-04-10 8:36 UTC (permalink / raw)
To: ruby-core
Issue #11055 has been reported by Nobuyoshi Nakada.
----------------------------------------
Bug #11055: autoload resets private_constant
https://bugs.ruby-lang.org/issues/11055
* Author: Nobuyoshi Nakada
* Status: Assigned
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* ruby -v: 50203
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Is this behavior intentional?
Suppose the following file:
~~~
$ cat a/b.rb
class A; B = 1; end
~~~
This causes `NameError`.
~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; end' -e 'p A::B'
-e:2:in `<main>': private constant A::B referenced (NameError)
~~~
But after it got loaded, `A::B` becomes public.
~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; B; end' -e 'p A::B'
1
~~~
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:94299] [Ruby master Bug#11055] autoload resets private_constant
[not found] <redmine.issue-11055.20150410083633@ruby-lang.org>
2015-04-10 8:36 ` [ruby-core:68831] [Ruby trunk - Bug #11055] [Assigned] autoload resets private_constant nobu
@ 2019-08-12 4:02 ` merch-redmine
2019-10-17 5:21 ` [ruby-core:95379] " matz
2 siblings, 0 replies; 3+ messages in thread
From: merch-redmine @ 2019-08-12 4:02 UTC (permalink / raw)
To: ruby-core
Issue #11055 has been updated by jeremyevans0 (Jeremy Evans).
File const-visibility-before-autoload-11055.patch added
I doubt dropping the existing constant visibility information is intentional behavior. You can work around the current behavior by resetting `private_constant`/`deprecate_constant` inside the autoloaded file, but that leads to duplication.
Attached is a patch that will copy the constant visibility information across the autoload.
----------------------------------------
Bug #11055: autoload resets private_constant
https://bugs.ruby-lang.org/issues/11055#change-80647
* Author: nobu (Nobuyoshi Nakada)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v: 50203
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Is this behavior intentional?
Suppose the following file:
~~~
$ cat a/b.rb
class A; B = 1; end
~~~
This causes `NameError`.
~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; end' -e 'p A::B'
-e:2:in `<main>': private constant A::B referenced (NameError)
~~~
But after it got loaded, `A::B` becomes public.
~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; B; end' -e 'p A::B'
1
~~~
---Files--------------------------------
const-visibility-before-autoload-11055.patch (3.93 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:95379] [Ruby master Bug#11055] autoload resets private_constant
[not found] <redmine.issue-11055.20150410083633@ruby-lang.org>
2015-04-10 8:36 ` [ruby-core:68831] [Ruby trunk - Bug #11055] [Assigned] autoload resets private_constant nobu
2019-08-12 4:02 ` [ruby-core:94299] [Ruby master Bug#11055] " merch-redmine
@ 2019-10-17 5:21 ` matz
2 siblings, 0 replies; 3+ messages in thread
From: matz @ 2019-10-17 5:21 UTC (permalink / raw)
To: ruby-core
Issue #11055 has been updated by matz (Yukihiro Matsumoto).
I agree with fixing this. Nobu will investigate the patch and consider the issue detail.
Matz.
----------------------------------------
Bug #11055: autoload resets private_constant
https://bugs.ruby-lang.org/issues/11055#change-82090
* Author: nobu (Nobuyoshi Nakada)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version:
* ruby -v: 50203
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
Is this behavior intentional?
Suppose the following file:
~~~
$ cat a/b.rb
class A; B = 1; end
~~~
This causes `NameError`.
~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; end' -e 'p A::B'
-e:2:in `<main>': private constant A::B referenced (NameError)
~~~
But after it got loaded, `A::B` becomes public.
~~~
$ ruby -I. -e 'class A;autoload :B, "a/b.rb"; private_constant :B; B; end' -e 'p A::B'
1
~~~
---Files--------------------------------
const-visibility-before-autoload-11055.patch (3.93 KB)
--
https://bugs.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-17 5:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <redmine.issue-11055.20150410083633@ruby-lang.org>
2015-04-10 8:36 ` [ruby-core:68831] [Ruby trunk - Bug #11055] [Assigned] autoload resets private_constant nobu
2019-08-12 4:02 ` [ruby-core:94299] [Ruby master Bug#11055] " merch-redmine
2019-10-17 5:21 ` [ruby-core:95379] " matz
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).