From: Nobuyoshi Nakada Date: 2008-10-06T00:28:19+09:00 Subject: [ruby-core:19129] Re: Autoload and class definition Hi, At Sun, 5 Oct 2008 11:27:42 +0900, Tomas Matousek wrote in [ruby-core:19127]: > I've found an interesting corner case of autoload behavior, which I think is wrong. It's not wrong. > Now, let's do the same using constant auto-loading instead: > > class F > autoload(:C, "load_c"); > > class C # => uninitialized constant F::C (NameError) > end > end > > It seems that autoload repeats the same constant resolution > semantics that triggered it (otherwise C would be found in M > and TypeError would be raised), yet it raises error if the > constant is not found. This seems to be a bug. I would expect > no exception. That autoload declares C must be defined in load_c, but it isn't. And class definition checks if the class is already defined, to reopen it. Your example is same as: autoload(:C, "load_c") C # => NameError -- Nobu Nakada c