
Extlib's Module::find_const does not work properly when searching siblings
Reported by Alexander Flatter | July 22nd, 2008 @ 10:05 PM
>> require 'extlib'
=> true
>> module Foo
>> module Bar
>> end
>> end
=> nil
>> Foo.find_const('Bar')
=> Foo::Bar
>> Foo.find_const('Baz')
=> Foo # Should raise NameError
>> Object.find_const('Bar')
NameError: NameError
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/module.rb:39:in `__nested_constants__'
from /Library/Ruby/Gems/1.8/gems/extlib-0.9.3/lib/extlib/module.rb:9:in `find_const'
from (irb):17
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/fileutils.rb:1239
Comments and changes to this ticket
-
-
-
Dan Kubb (dkubb) July 23rd, 2008 @ 02:15 AM
- State changed from new to resolved
- Tag changed from extlib, module to bug, extlib, module, spec
- Assigned user changed from Sam Smoot to Dan Kubb (dkubb)
This should be resolved by the following commit:
-
Alexander Flatter July 23rd, 2008 @ 08:26 AM
Looks like that patch messed up auto migrations... Perhaps that bug provoked more bugs in dm-core.
I did reimplement that method too but you committed earlier (+ your version performed better) :-)
-
-
Dan Kubb (dkubb) July 23rd, 2008 @ 03:23 PM
I was actually thinking that prior to this change the system wouldn't throw a NameError exception when it should be doing so, since in your example Foo.find_const('Baz') returned Foo, and not NameError like it should be. I really like systems that "fail fast" when something is wrong, rather than try to hobble along like nothing happened, so I view this as a good thing.
-
Sam Smoot July 23rd, 2008 @ 03:29 PM
Dan,
Right. Should raise a NameError. The idea is that #find_const should be a 100% drop-in replacement for #get_const, that just happens to be a bit more flexible in how it finds nested or sibling constants.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »