Actions
Bug #10276
closednil/true/false に singleton メソッドを定義できてしまう
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.0dev (2014-09-21 trunk 47672) [x86_64-linux]
Backport:
Description
nil/true/false が frozen object なのに singleton メソッドを定義できてしまいます。
% cat /tmp/f.rb
def d(o)
p o.frozen?
def o.m; end
rescue
p [o, $!]
end
d(:sym)
d(1)
d(nil)
d(true)
d(false)
d(Object.new.freeze)
% ruby -v /tmp/f.rb
ruby 2.2.0dev (2014-09-21 trunk 47672) [x86_64-linux]
true
[:sym, #<TypeError: can't define singleton>]
true
[1, #<TypeError: can't define singleton>]
true
true
true
true
[#<Object:0x00000002706730>, #<RuntimeError: can't modify frozen object>]
Actions
Like0
Like0Like0Like0