Hey, I am experimenting with decorated Kernel#require and hacked paths, and
while everything works as expected, this use case doesn't:

  module Kernel
    alias original_require require
    def require(path)
      if path == "hacked"
        original_require("user")
      else
        original_require(path)
      end
    end
  end

  Object.autoload(:User, "hacked")
  User

In user.rb we have "class User; end" and the error message is

  uninitialized constant User (NameError)
  Did you mean?  User

Note that we are suggested User!

If "user.rb" contains "User = 1" or "User = Class.new", no problem.

Also, it is interesting that if we define the autoload in the decoration
again:

  module Kernel
    alias original_require require
    def require(path)
      if path == "hacked"
        Object.autoload(:User, "user")
        original_require("user")
      else
        original_require(path)
      end
    end
  end

  Object.autoload(:User, "hacked")
  User

it works fine too, the User class is loaded.

Could that be a bug in the autoload code triggered by the class/module
keywords?
(supressed text/html)
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>