ActionsLike0
Bug #2679
closedrubyspec: SimpleDelegator when frozen creates a frozen clone ERROR
Description
=begin
まつもとさん、または lib/delegator.rb についてわかる誰か
遠藤です。
freeze した SimpleDelegator を clone できません。
$ ./ruby -rdelegate -e '
a = [42, :hello]
d = SimpleDelegator.new(a)
d.freeze
d.clone
'
/home/mame/work/ruby-trunk-local/lib/ruby/1.9.1/delegate.rb:257:in
__setobj__': can't modify frozen object (RuntimeError) from /home/mame/work/ruby-trunk-local/lib/ruby/1.9.1/delegate.rb:207:in
clone'
from -e:5:in `'
これはバグですよね。
lib/delegator.rb の clone の定義を見ると
def clone
new = super
new.setobj(getobj.clone)
new
end
となっていて、setobj するときにはもう SimpleDelegetor は freeze
状態なのでそりゃそうだという感じなんですが、どう直したものでしょう。
--
Yusuke ENDOH mame@tsg.ne.jp
=end
Updated by matz (Yukihiro Matsumoto) about 15 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
Updated by mame (Yusuke Endoh) about 15 years ago
- Category set to lib
- Status changed from Closed to Open
- Assignee set to matz (Yukihiro Matsumoto)
- Priority changed from 3 to Normal
- Target version set to 2.0.0
- ruby -v set to ruby 1.9.2dev (2010-01-29 trunk 26468) [i686-linux]
Updated by mame (Yusuke Endoh) about 15 years ago
- Status changed from Closed to Open
- Assignee changed from matz (Yukihiro Matsumoto) to nobu (Nobuyoshi Nakada)
ActionsLike0