Project

General

Profile

Actions

Bug #3949

closed

Can predefined classes be removed?

Added by yugui (Yuki Sonoda) over 13 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.6.8 (2005-09-21) [i386-darwin9.1.0]
Backport:
[ruby-core:32797]

Description

=begin
According to rdoc, Module#remove_const cannot remove predefined classes:

Predefined classes and singleton objects (such as true) cannot be
removed.

But actually we can remove them.
$ ruby-1.8.0 -ve 'Object.send(:remove_const, :String); p String'
ruby 1.8.0 (2003-08-04) [i686-darwin]
-e:1: uninitialized constant String (NameError)
$ ruby-1.8.1 -ve 'Object.send(:remove_const, :String); p String'
ruby 1.8.1 (2003-12-25) [i686-darwin]
-e:1: uninitialized constant String (NameError)
...
$ ruby-1.9.1 -ve 'Object.send(:remove_const, :String); p String'
ruby 1.9.1p427 (2010-05-23 revision 27982) [i386-darwin9.8.0]
-e:1:in <main>': uninitialized constant String (NameError) $ ruby-1.9.2 -ve 'Object.send(:remove_const, :String); p String' ruby 1.9.2p6 (2010-08-18 revision 29252) [i386-darwin9.8.0] -e:1:in ': uninitialized constant Object::String (NameError)

The rdoc seems to be describing Ruby 1.6:

ruby-1.6 -ve 'Object.send(:remove_const, :String); p String'
$ ruby 1.6.8 (2005-09-21) [i386-darwin9.1.0]
-e:1:in remove_const': cannot remove Object::String (NameError) from -e:1:in send'
from -e:1

This limitation is intended? or is the rdoc wrong? I think we should be able to remove any class on our own risk.
=end


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #3769: Removing Predefined ConstantsClosed08/31/2010Actions
Actions #1

Updated by runpaint (Run Paint Run Run) over 13 years ago

=begin
I asked about this in #3769 . nobu seemed to imply the documentation was at fault.
=end

Actions #2

Updated by nobu (Nobuyoshi Nakada) over 13 years ago

  • Status changed from Open to Closed

=begin
This issue was solved with changeset r29519.
Run Paint, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0