Re: Unnecessary exception raised in AS::Dependencies.load_missing_constant

Andrew White
2010-02-15T13:19:56Z

On 15 Feb 2010, at 12:11, Yehuda Katz wrote:

> I couldn''t think of or find any reason for these cases to be
different. My guess is that the behavior was added to classes at some point (due
to STI needs) but never added to modules (since it never came up). In any event,
there''s no way to deal with:

I agree - there''s no valid reason that the lookup shouldn''t
always go foo/bar/baz.rb, foo/baz.rb & baz.rb - missing out the middle one
seems illogical. I''d keep your normalisation changes even if your patch
for Ruby was accepted. In fact your normalisation changes will make it more
likely that the "is not missing constant" error is raised as
we''re checking for more places where it might be found, e.g:

Taking your Foo::Bar::Baz example:

>> "Foo::Bar::Baz".constantize
ArgumentError: Foo is not missing constant Baz!

>> "Foo::Bar".const_get("Baz")
ArgumentError: Foo is not missing constant Baz!

If we check for the presence of the constant before calling
load_missing_constant then we prevent these errors. Okay it may be not the
cleanest or the correct solution but the alternatives aren''t great.


Andrew White