ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:67591] [ruby-trunk - Bug #10741] [Open] const_defined? triggers autoload where it did not before
       [not found] <redmine.issue-10741.20150114210920@ruby-lang.org>
@ 2015-01-14 21:09 ` headius
  2015-01-14 21:11 ` [ruby-core:67592] [ruby-trunk - Bug #10741] " headius
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: headius @ 2015-01-14 21:09 UTC (permalink / raw
  To: ruby-core

Issue #10741 has been reported by Charles Nutter.

----------------------------------------
Bug #10741: const_defined? triggers autoload where it did not before
https://bugs.ruby-lang.org/issues/10741

* Author: Charles Nutter
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.0.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
This should not cause b.rb to load, but it does in 2.2:

~/projects/jruby $ cat a.rb
module Foo
  autoload :Bar, 'b.rb'
end

p Foo.const_defined?('Bar')

~/projects/jruby $ cat b.rb
puts "in b"
module Foo
  Bar = 1
end

~/projects/jruby $ rvm ruby-2.0 do ruby -I. a.rb
true

~/projects/jruby $ rvm ruby-2.1 do ruby -I. a.rb
in b
true

~/projects/jruby $ rvm ruby-2.2 do ruby -I. a.rb
in b
true

This is likely caused by the :: support in const_get/const_defined not doing autoload-free traversal.



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:67592] [ruby-trunk - Bug #10741] const_defined? triggers autoload where it did not before
       [not found] <redmine.issue-10741.20150114210920@ruby-lang.org>
  2015-01-14 21:09 ` [ruby-core:67591] [ruby-trunk - Bug #10741] [Open] const_defined? triggers autoload where it did not before headius
@ 2015-01-14 21:11 ` headius
  2015-01-14 21:15 ` [ruby-core:67593] " headius
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 5+ messages in thread
From: headius @ 2015-01-14 21:11 UTC (permalink / raw
  To: ruby-core

Issue #10741 has been updated by Charles Nutter.


Test in JRuby that caught this change: https://github.com/jruby/jruby/blob/master/test/jruby/test_autoload.rb#L4-L24

Fix in JRuby: https://github.com/jruby/jruby/commit/496c638d2419e089e93eec9759d9775de0390901

----------------------------------------
Bug #10741: const_defined? triggers autoload where it did not before
https://bugs.ruby-lang.org/issues/10741#change-51012

* Author: Charles Nutter
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.0.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
This should not cause b.rb to load, but it does in 2.2:

~/projects/jruby $ cat a.rb
module Foo
  autoload :Bar, 'b.rb'
end

p Foo.const_defined?('Bar')

~/projects/jruby $ cat b.rb
puts "in b"
module Foo
  Bar = 1
end

~/projects/jruby $ rvm ruby-2.0 do ruby -I. a.rb
true

~/projects/jruby $ rvm ruby-2.1 do ruby -I. a.rb
in b
true

~/projects/jruby $ rvm ruby-2.2 do ruby -I. a.rb
in b
true

This is likely caused by the :: support in const_get/const_defined not doing autoload-free traversal.



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:67593] [ruby-trunk - Bug #10741] const_defined? triggers autoload where it did not before
       [not found] <redmine.issue-10741.20150114210920@ruby-lang.org>
  2015-01-14 21:09 ` [ruby-core:67591] [ruby-trunk - Bug #10741] [Open] const_defined? triggers autoload where it did not before headius
  2015-01-14 21:11 ` [ruby-core:67592] [ruby-trunk - Bug #10741] " headius
@ 2015-01-14 21:15 ` headius
  2015-01-14 22:15 ` [ruby-core:67594] " headius
  2019-07-08  1:21 ` [ruby-core:93602] [Ruby master Bug#10741] " merch-redmine
  4 siblings, 0 replies; 5+ messages in thread
From: headius @ 2015-01-14 21:15 UTC (permalink / raw
  To: ruby-core

Issue #10741 has been updated by Charles Nutter.


To be more specific, this assertion fails on MRI:

>assert_equal("#{File.dirname(__FILE__)}/autoloaded.rb", Object.autoload?("Autoloaded"))

Because the previous const_defined? call has already triggered the autoload.

----------------------------------------
Bug #10741: const_defined? triggers autoload where it did not before
https://bugs.ruby-lang.org/issues/10741#change-51013

* Author: Charles Nutter
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.0.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
This should not cause b.rb to load, but it does in 2.2:

~/projects/jruby $ cat a.rb
module Foo
  autoload :Bar, 'b.rb'
end

p Foo.const_defined?('Bar')

~/projects/jruby $ cat b.rb
puts "in b"
module Foo
  Bar = 1
end

~/projects/jruby $ rvm ruby-2.0 do ruby -I. a.rb
true

~/projects/jruby $ rvm ruby-2.1 do ruby -I. a.rb
in b
true

~/projects/jruby $ rvm ruby-2.2 do ruby -I. a.rb
in b
true

This is likely caused by the :: support in const_get/const_defined not doing autoload-free traversal.



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:67594] [ruby-trunk - Bug #10741] const_defined? triggers autoload where it did not before
       [not found] <redmine.issue-10741.20150114210920@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2015-01-14 21:15 ` [ruby-core:67593] " headius
@ 2015-01-14 22:15 ` headius
  2019-07-08  1:21 ` [ruby-core:93602] [Ruby master Bug#10741] " merch-redmine
  4 siblings, 0 replies; 5+ messages in thread
From: headius @ 2015-01-14 22:15 UTC (permalink / raw
  To: ruby-core

Issue #10741 has been updated by Charles Nutter.


Boo...my fix was bad because it stopped searching superclasses. Since I did not have an appropriate method to search superclasses, split up :: elements, and check private consts all in one, I reverted JRuby to the autoload-inducing state for now: https://github.com/jruby/jruby/commit/ccfee85c717a8235d18c63aacfe5f015f4f14261

Tagged some specs and removed an assertion in JRuby's test: https://github.com/jruby/jruby/commit/cffeaab92d5a893240f6ba35159c29eb4cc8d4d5

----------------------------------------
Bug #10741: const_defined? triggers autoload where it did not before
https://bugs.ruby-lang.org/issues/10741#change-51014

* Author: Charles Nutter
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.0.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
This should not cause b.rb to load, but it does in 2.2:

~/projects/jruby $ cat a.rb
module Foo
  autoload :Bar, 'b.rb'
end

p Foo.const_defined?('Bar')

~/projects/jruby $ cat b.rb
puts "in b"
module Foo
  Bar = 1
end

~/projects/jruby $ rvm ruby-2.0 do ruby -I. a.rb
true

~/projects/jruby $ rvm ruby-2.1 do ruby -I. a.rb
in b
true

~/projects/jruby $ rvm ruby-2.2 do ruby -I. a.rb
in b
true

This is likely caused by the :: support in const_get/const_defined not doing autoload-free traversal.



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:93602] [Ruby master Bug#10741] const_defined? triggers autoload where it did not before
       [not found] <redmine.issue-10741.20150114210920@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2015-01-14 22:15 ` [ruby-core:67594] " headius
@ 2019-07-08  1:21 ` merch-redmine
  4 siblings, 0 replies; 5+ messages in thread
From: merch-redmine @ 2019-07-08  1:21 UTC (permalink / raw
  To: ruby-core

Issue #10741 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Closed

This was fixed between 2.6 and 2.7.0-preview1:

```
$ ruby26 a.rb  
in b
true

$ ruby27 a.rb  
true
```

----------------------------------------
Bug #10741: const_defined? triggers autoload where it did not before
https://bugs.ruby-lang.org/issues/10741#change-79196

* Author: headius (Charles Nutter)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.0.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
This should not cause b.rb to load, but it does in 2.2:

~/projects/jruby $ cat a.rb
module Foo
  autoload :Bar, 'b.rb'
end

p Foo.const_defined?('Bar')

~/projects/jruby $ cat b.rb
puts "in b"
module Foo
  Bar = 1
end

~/projects/jruby $ rvm ruby-2.0 do ruby -I. a.rb
true

~/projects/jruby $ rvm ruby-2.1 do ruby -I. a.rb
in b
true

~/projects/jruby $ rvm ruby-2.2 do ruby -I. a.rb
in b
true

This is likely caused by the :: support in const_get/const_defined not doing autoload-free traversal.



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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-07-08  1:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-10741.20150114210920@ruby-lang.org>
2015-01-14 21:09 ` [ruby-core:67591] [ruby-trunk - Bug #10741] [Open] const_defined? triggers autoload where it did not before headius
2015-01-14 21:11 ` [ruby-core:67592] [ruby-trunk - Bug #10741] " headius
2015-01-14 21:15 ` [ruby-core:67593] " headius
2015-01-14 22:15 ` [ruby-core:67594] " headius
2019-07-08  1:21 ` [ruby-core:93602] [Ruby master Bug#10741] " merch-redmine

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).