Issue #11714 has been updated by Shugo Maeda.

Status changed from Open to Rejected

Antonio Terceiro wrote:
> 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'

It's not a regression.
Even in Ruby 2.1, `include MyThing` affects date.rb, but it doesn't affect `Date` because ::Date is defined by RubyGems before inclusion of `MyThing`.

You can see the same error in Ruby 2.1 by the option `--disable=gems`:
```
$ ruby --disable=gems test.rb
```

Without --disable=gems, you can see that `Date` is not affected by inclusion of `MyThing` even in test.rb:

```
module MyThing
  class Date < String
  end
end
include MyThing
p Date #=> Date, not MyThing::Date
```


----------------------------------------
Bug #11714: `include Module` affects scope of code loaded by require statements on Ruby 2.2+
https://bugs.ruby-lang.org/issues/11714#change-55538

* Author: Antonio Terceiro
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-11-19 master 52671) [x86_64-linux]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
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>'
~~~




-- 
https://bugs.ruby-lang.org/