Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

dependencies marks regular constants as autoloaded

#5165

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.

Reported by Xavier Noria · July 21st, 2010 @ 12:48 AM

State: resolved
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: High

Activity

  1. Xavier Noria
    Xavier Noria
    • Importance changed from Low to High

    July 21st, 2010 @ 12:54 AM

  2. Repository
    Repository
    • State changed from new to resolved

    (from [1b97701e51667e6040b4c576cce9234edef1019e]) Fix a bug where requires inside of autoloads were being added to the autoloaded_constants list, causing mayhem. [#5165 dependencies marks regular constants as autoloaded state:resolved] http://github.com/rails/rails/commit/1b97701e51667e6040b4c576cce923...

    July 26th, 2010 @ 09:00 AM

  3. Jeremy Kemper