I've found an interesting corner case of autoload behavior, which I think is wrong.
Let's create a file load_c.rb with following 2 definitions:

module M
  C = 1
end

class F
  include M
end

---

Now this works:

class F
  require 'load_c'
  class C                # [1]
  end
end

It's because the class definition [1] of C doesn't look for constant C in included modules, only in the class F itself (if it did look in the includedodules we would indeed get "C is not a class" TypeError).

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.

Tomas