From: Johan Holmberg Date: 2009-02-12T18:49:45+09:00 Subject: [ruby-core:22033] 1.9.1 & Kernel.load(..., true) --> scope problem? Hi! I recently tried to use MRI 1.9.1 for one of my existing scripts. But I soon found that Kernel.load works differently in MRI 1.9.1 (and broke my script). Here is a minimal example, showing the problem: # file: loader.rb load "./loaded.rb", true # file: loaded.rb class Foo def hello puts "This is a Foo" end end class Bar def hello puts "This is a Bar" Foo.new.hello # 'Foo' not found in MRI 1.9.1 end end Bar.new.hello When I run the "loader.rb" script in MRI 1.8.6 and JRuby 1.1.6 (with or without the "--1.9" switch) I get the following output: This is a Bar This is a Foo This is what I expect. But in MRI 1.9.1 I get an error like this: loaded.rb:11:in `hello': uninitialized constant #::Bar::Foo (NameError) from /Users/holmberg/test/ruby/loaded.rb:15:in `' from loader.rb:2:in `load' from loader.rb:2:in `
' I have used "Kernel.load(..., true)" on several occasions, when I want to avoid polluting the global namespace. It seems natural that classes defined in the same file should "find" each other, even when we are in an anonymous module. Is this an intentional change, or a bug in MRI 1.9.1 ? Regards, /Johan Holmberg