From: Joel VanderWerf Date: 2004-11-01T03:21:54+09:00 Subject: Re: [BUG] autoload ts wrote: >>>>>>"J" == Joel VanderWerf writes: > > > J> Something has changed in 1.9 snapshots in the last week that is breaking > J> my autoloads. > > This is this [ruby-list:40085] The issue seems to be whether or not foo.rb should be added to $" before loading the file. As of 2004-10-29, the stable snapshot says yes, but the 1.9 snapshot says no: $ cat f1.rb require 'f2' p $" $ cat f2.rb p $" $ ruby-snapshot -v f1.rb ruby 1.9.0 (2004-10-29) [i686-linux] [] ["f2.rb"] $ ruby-stable-snapshot -v f1.rb ruby 1.8.2 (2004-10-29) [i686-linux] ["f2.rb"] ["f2.rb"] The reason for this change seems to be in case an exception happens in the required file, and then the calling code detects the exception and tries to require it again. This makes sense. It's interesting that circular requires are still handled correctly without using $". There is loading_tbl variable in eval.c that keeps track of what all threads are trying to load. Only when a load is finished does the feature name get pushed onto $". Antoher interesting point: rb_autoload_load() first calls autoload_delete(), which is the source of my problem. The :Bug2=>"bug1" entry is being deleted, but the :Bug1=>"bug1" entry is not. So when "class Bug1; end" is found at the top of bug1.rb, ruby tries to autoload "bug1.rb", but sees that this file is already in the loading_tbl, and does not load it. Thus the undefined constant. So maybe rb_autoload_load() should delete _all_ entries that refer to the same file name as the one currently being autoloaded?