This project is archived and is in readonly mode.

#5165 ✓resolved
Xavier Noria

dependencies marks regular constants as autoloaded

Reported by Xavier Noria | July 21st, 2010 @ 12:48 AM | in 3.0.2

This happens when there are 2 or more const_missings in a row:

fxn@rails:~/tmp/autoload$ cat lib/m.rb
module M
end
fxn@rails:~/tmp/autoload$ cat app/models/a.rb 
module A
end
B
fxn@rails:~/tmp/autoload$ cat app/models/b.rb 
require 'm'

module B
end
fxn@rails:~/tmp/autoload$ sr 'A; p ActiveSupport::Dependencies.autoloaded_constants'
["B", "M", "A"]

See the "M" there?

As a consequence, that M will be removed in dev mode, but never loaded again because "m.rb" correctly belongs to $" after that.

Interestingly, if you move the require line from b.rb to a.rb and execute the same runner script, M is not marked as autoloaded, albeit it was a new constant resulting from autoloading A. Which is the correct behavior.

This is a regression, 2.3 does not have this issue.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages