Project

General

Profile

ActionsLike0

Bug #2679

closed

rubyspec: SimpleDelegator when frozen creates a frozen clone ERROR

Added by mame (Yusuke Endoh) about 15 years ago. Updated almost 14 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 1.9.2dev (2010-01-29 trunk 26468) [i686-linux]
Backport:
[ruby-dev:40221]

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
=end


Related issues 1 (0 open1 closed)

Has duplicate Ruby - Bug #2221: lib/delegate: freeze has odd effectsClosed10/16/2009Actions
#3

Updated by matz (Yukihiro Matsumoto) about 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
#5

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]
#6

Updated by nobu (Nobuyoshi Nakada) about 15 years ago

  • Status changed from Open to Closed
#8

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)
#13

Updated by mame (Yusuke Endoh) almost 15 years ago

  • Status changed from Open to Closed
ActionsLike0

Also available in: Atom PDF