Project

General

Profile

Actions

Bug #11714

closed

`include Module` affects scope of code loaded by require statements on Ruby 2.2+

Added by terceiro (Antonio Terceiro) over 6 years ago. Updated over 6 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-11-19 master 52671) [x86_64-linux]
[ruby-core:71583]

Description

This seems to be a regression with Ruby 2.2 and beyond, I can still reproduce this in Ruby trunk from today. Ruby 2.1 works just fine.

$ cat /tmp/test.rb 
module MyThing
  class Date < String
  end
end
include MyThing

require 'date'
$ ruby2.1 /tmp/test.rb 
$ ruby2.2 /tmp/test.rb 
/usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': superclass mismatch for class Date (TypeError)
	from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /usr/lib/ruby/2.2.0/date.rb:3:in `<top (required)>'
	from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /usr/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /tmp/test.rb:7:in `<main>'
[1]$ /var/tmp/ruby-trunk/bin/ruby /tmp/test.rb
/var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require': superclass mismatch for class Date (TypeError)
	from /var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /var/tmp/ruby-trunk/lib/ruby/2.3.0/date.rb:3:in `<top (required)>'
	from /var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /var/tmp/ruby-trunk/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /tmp/test.rb:7:in `<main>'
Actions

Also available in: Atom PDF