From: Christopher Dicely Date: 2011-06-09T09:39:47+09:00 Subject: Re: a little challenge - reproduce this error On Wed, Jun 8, 2011 at 8:27 AM, Intransition wrote: > On Jun 8, 10:56 am, Christopher Dicely wrote: >> >> The top-level X (and the Foo underneath it) seems required to get the >> error, so that doesn't make it harder. If you reference X::Foo::X >> without X existing, you'll get >> uninitialized constant Object::X (NameError) >> >> If you reference X::Foo::X with just the part you have above, you'll >> get uninitialized constant X::Foo (NameError) >> >> The easiest way to get the error you ask about is >> module X; module Foo; end; end >> X::Foo::X > > Well, Balls. That in itself seems ridiculous, but you are right. I'm > not sure why it raises that though. Maybe the code is silly, but is it > really wrong? Try X::Foo.const_get(:X) and it works fine. Seems > inconsistent, doesn't it? Not really. I'd expect X::Foo::X to get the constant at that path (which doesn't exist, hence the error), while X::Foo.const_get(:X) I'd expect to resolve as if X was referenced within X::Foo, including climbing up the chain, and to return the top-level X. > >> But I would guess that that probably isn't what you are looking for >> either. > > Yes, in the actual code X is being referenced from within Foo but is > not fully qualified. I could swear that I have run into that error in some things in the past (and resolved it by fully qualifying the affected references), but now I can't figure out how to reproduce it.