[Bug:trunk] rubyspec: SimpleDelegator when frozen creates a frozen clone ERROR

e$B$^$D$b$H$5$s!"$^$?$Oe(B lib/delegator.rb e$B$K$D$$$F$o$+$kC/$+e(B
e$B1sF#$G$9!#e(B

freeze e$B$7$?e(B SimpleDelegator e$B$re(B clone e$B$G$-$^$;$s!#e(B

$ ./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:inclone’
from -e:5:in `’

e$B$3$l$O%P%0$G$9$h$M!#e(B

lib/delegator.rb e$B$Ne(B clone e$B$NDj5A$r8+$k$He(B

def clone
new = super
new.setobj(getobj.clone)
new
end

e$B$H$J$C$F$$$F!“e(B__setobj__ e$B$9$k$H$-$K$O$b$&e(B SimpleDelegetor
e$B$Oe(B freeze
e$B>uBV$J$N$G$=$j$c$=$&[email protected]$H$$$&46$8$J$s$G$9$,!”$I$&D>$7$?$b$N$G$7$g$&!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40221] [Bug:trunk] rubyspec: SimpleDelegator
when frozen creates a frozen clone ERROR”
on Fri, 29 Jan 2010 01:18:07 +0900, Yusuke ENDOH [email protected]
writes:

|freeze e$B$7$?e(B SimpleDelegator e$B$re(B clone e$B$G$-$^$;$s!#e(B
|e$B$3$l$O%P%0$G$9$h$M!#e(B

e$B%P%[email protected]$H;W$$$^$9!#e(B

|lib/delegator.rb e$B$Ne(B clone e$B$NDj5A$r8+$k$He(B
|
| def clone
| new = super
| new.setobj(getobj.clone)
| new
| end
|
|e$B$H$J$C$F$$$F!“e(B__setobj__ e$B$9$k$H$-$K$O$b$&e(B SimpleDelegetor e$B$Oe(B freeze
|e$B>uBV$J$N$G$=$j$c$=$&[email protected]$H$$$&46$8$J$s$G$9$,!”$I$&D>$7$?$b$N$G$7$g$&!#e(B

e$B:$$j$^$7$?$M$(!#$A$g$C$H9M$($F$_$^$9!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40222] Re: [Bug:trunk] rubyspec:
SimpleDelegator when frozen creates a frozen clone ERROR”
on Fri, 29 Jan 2010 01:36:27 +0900, Yukihiro M.
[email protected] writes:

||lib/delegator.rb e$B$Ne(B clone e$B$NDj5A$r8+$k$He(B
||
|| def clone
|| new = super
|| new.setobj(getobj.clone)
|| new
|| end
||
||e$B$H$J$C$F$$$F!“e(B__setobj__ e$B$9$k$H$-$K$O$b$&e(B SimpleDelegetor e$B$Oe(B freeze
||e$B>uBV$J$N$G$=$j$c$=$&[email protected]$H$$$&46$8$J$s$G$9$,!”$I$&D>$7$?$b$N$G$7$g$&!#e(B
|
|e$B:$$j$^$7$?$M$(!#$A$g$C$H9M$($F$_$^$9!#e(B

e$B$=$&$$$($P!"$3$s$J;~$N$?$a$Ke(Binitialize_copye$B$H$$$&%a%=%C%I$rMQe(B
e$B0U$7$F$*$$$?$N$G$7$?!#$G$b!":#EY$Oe(Bclonee$B$He(Bdupe$B$N6hJL$,$D$+$J$$e(B
([email protected]7W%%9e(B)e$B!#$b$7!"[email protected]$,LdBj$K$J$k$h$&$J$ie(B
e$B65$($F$/[email protected]$5$$!#e(B

e$B%A%1%C%He(B #2679 e$B$,99?7$5$l$^$7$?!#e(B (by Yukihiro M.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B
e$B?JD=e(B % 0e$B$+$ie(B100e$B$KJQ99e(B

This issue was solved with changeset r26462.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


http://redmine.ruby-lang.org/issues/show/2679

e$B%A%1%C%He(B #2679 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B%+%F%4%je(B libe$B$K%;%C%He(B
e$B%9%F!<%?%9e(B Closede$B$+$ie(BOpene$B$KJQ99e(B
e$BC4Ev<Te(B Yukihiro M.e$B$K%;%C%He(B
e$BM%@hEYe(B Lowe$B$+$ie(BNormale$B$KJQ99e(B
Target version 1.9.xe$B$K%;%C%He(B
ruby -v ruby 1.9.2dev (2010-01-29 trunk 26468)
[i686-linux]e$B$K%;%C%He(B

$ ./ruby -rdelegate -e ’
a = [42, :hello].freeze
d = SimpleDelegator.new(a)
d.dup[0] += 1

-e:4:in `’: can’t modify frozen array (RuntimeError)

e$BK:$l$i$l$J$$$h$&$Ke(B reopen e$B$7$F$*$-$^$9!#e(B


Yusuke E. [email protected]

http://redmine.ruby-lang.org/issues/show/2679

e$B1sF#$G$9!#e(B

2010e$BG/e(B1e$B7ne(B29e$BF|e(B1:49 Yukihiro M.
[email protected]:

|
|e$B:$$j$^$7$?$M$(!#$A$g$C$H9M$($F$_$^$9!#e(B

e$B$=$&$$$($P!"$3$s$J;~$N$?$a$Ke(Binitialize_copye$B$H$$$&%a%=%C%I$rMQe(B
e$B0U$7$F$*$$$?$N$G$7$?!#$G$b!":#EY$Oe(Bclonee$B$He(Bdupe$B$N6hJL$,$D$+$J$$e(B
([email protected]7W%%9e(B)e$B!#$b$7!"[email protected]$,LdBj$K$J$k$h$&$J$ie(B
e$B65$($F$/[email protected]$5$$!#e(B

(e$B$$$$2C8:$K;n$7$?$H$3$me(B) rubyspec e$B$He(B test-all
e$B$H$b$K%Q%9$7$?$N$G$9$,!"e(B
e$B0J2<$N$h$&$J%3!<%I$,F0$+$J$/$J$j$^$7$?!#e(B

$ ./ruby -rdelegate -e ’
a = [42, :hello].freeze
d = SimpleDelegator.new(a)
d.dup[0] += 1

-e:4:in `’: can’t modify frozen array (RuntimeError)

e$B%A%1%C%He(B #2679 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)

e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B

This issue was solved with changeset r26566.
Yusuke, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


http://redmine.ruby-lang.org/issues/show/2679

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40312] Bug #2679 rubyspec:
SimpleDelegator when frozen creates a frozen clone ERROR”
on Thu, 4 Feb 2010 08:17:45 +0900, Nobuyoshi N.
[email protected] writes:

|e$B%A%1%C%He(B #2679 e$B$,99?7$5$l$^$7$?!#e(B (by Nobuyoshi N.)
|e$B%9%F!<%?%9e(B Opene$B$+$ie(BClosede$B$KJQ99e(B

[email protected]$G$9$,!“e(BSimpleDelegator.dupe$B$,JV$9%*%V%8%’%/%H$Ne(Bclass
e$B$,e(BSimpleDelegatore$B$G$J$/$J$C$F$^$9!#$=$l$O$=$l$GLdBj$,$”$k$he(B
e$B$&$J!#e(B

a = [42, :hello].freeze
d = SimpleDelegator.new(a)
d.dup.class # e$B0JA0e(B SimpleDelegator, e$B8=:_e(B Array

e$B$I$&$J$s$G$7$g$&$M!#e(B

e$B%A%1%C%He(B #2679 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

e$B%9%F!<%?%9e(B Closede$B$+$ie(BOpene$B$KJQ99e(B
e$BC4Ev<Te(B Yukihiro M.e$B$+$ie(BNobuyoshi N.e$B$KJQ99e(B

e$B1sF#$G$9!#e(B

rubyspec e$B$Ge(B delegate e$B$N%(%i!<$,e(B 5 e$B$DA}$($^$7$?!#e(B
tempfile e$B$be(B 10 e$B8D$/$i$$<:GT$9$k$h$&$K$J$C$?$h$&$G$9!#e(B
e$BFq$7$$$G$9$M!#e(B

e$BK]Lu$9$k$H!"0J2<$N$h$&$K5sF0$,JQ$o$C$?$h$&$G$9!#e(B

1) freeze e$B$7$F$be(B setobj e$B$G$-$F$7$^$&e(B

$ ./ruby -rdelegate -e ’
d = SimpleDelegator.new([1, :foo])
d.freeze
d.setobj(“foo”) # e$B0JA0$O$3$3$GNc30e(B
p d

“foo”

2) frozen? e$B$,e(B delegate e$B85$Ne(B freeze e$B>uBV$rJV$9e(B

(e$B$3$l$O$`$7$m2~A1!)e(B)

$ ./ruby -rdelegate -e ’
p SimpleDelegator.new([1, :foo].freeze).frozen?

true # e$B0JA0$Oe(B false

3) SimpleDelegator#method e$B$N8e$Ge(B setobj

e$B$r8F$S=P$7$F$+$ie(B call e$B$G$-$ke(B

$ ./ruby -rdelegate -e ’
s = SimpleDelegator.new(“foo”)
m = s.method(“upcase”)
s.setobj([1,2,3])
p m.call # e$B0JA0$O$3$3$GNc30e(B

“FOO”

4) delegate e$B85$Ne(B private method e$B$,IaDL$K8F$S=P$;$F$7$^$&e(B

(e$B=EBge(B)

$ ./ruby -rdelegate -e ’
class C
def foo
p :foo!
end
private :foo
end
SimpleDelegator.new(C.new).foo # e$B0JA0$ONc30e(B

foo!

5) delegate e$B85$Ne(B private method e$B$O0JA0$Oe(B send

e$B$G$b8F$S=P$;$J$+$C$?e(B

$ ./ruby -rdelegate -e ’
class C
def foo
p :foo!
end
private :foo
end
SimpleDelegator.new(C.new).send(:foo) # e$B0JA0$ONc30e(B

foo!


Yusuke ENDOH [email protected]

http://redmine.ruby-lang.org/issues/show/2679

[email protected]$G$9!#e(B

At Thu, 4 Feb 2010 12:43:19 +0900,
Yusuke E. wrote in [ruby-dev:40314]:

2) frozen? e$B$,e(B delegate e$B85$Ne(B freeze e$B>uBV$rJV$9e(B (e$B$3$l$O$`$7$m2~A1!)e(B)

$ ./ruby -rdelegate -e ’
p SimpleDelegator.new([1, :foo].freeze).frozen?

true # e$B0JA0$Oe(B false

e$B$3$l$O$I$C$A$N$[$&$,$$$$$s$G$7$g$&$M$’!#e(B


foo!


foo!

e$B$`$7$me(Bsende$B$G$b8F$Y$J$$$[$&$,%P%0$8$c$J$$$+$H$$$&5$$,$7$^$9$,!"e(B
method_missinge$B$G$O$I$&8F$S=P$5$l$?$+$OJ,$+$i$J$$$N$Ge(B#4e$B$He(B#5e$B$G0c$&e(B
e$BF0:n$K$O$G$-$^$;$s$M!#e(B

e$B1sF#$G$9!#e(B

2010e$BG/e(B2e$B7ne(B5e$BF|e(B16:39 Nobuyoshi N.
[email protected]:

4) delegate e$B85$Ne(B private method e$B$,IaDL$K8F$S=P$;$F$7$^$&e(B (e$B=EBge(B)

snip

e$B$`$7$me(Bsende$B$G$b8F$Y$J$$$[$&$,%P%0$8$c$J$$$+$H$$$&5$$,$7$^$9$,!"e(B

[email protected]$C$?$N$O!"e(B[ruby-core:26122] e$B$G!Ve(Bpublic method
e$B$7$+e(B delegate
e$B$7$J$$!W$H$$$&$^$D$b$H$5$s$NJ}?K$,<($5$l$F$$$k$?$a$G$9!#e(B
e$B$=$l$r:,5r$Ke(B rubyspec
[email protected]$7$?$N$O;d$J$N$G$A$g$C$H5$$^$:$$$G$9$,!"e(B
e$B%-%c%s%;%k$5$l$k$H$$$&$3$H$J$i:[email protected]$7$^$9!#e(B

e$B$^$D$b$H$5$s!"$I$&$7$^$9!)e(B

e$B1sF#$G$9!#e(B

2010e$BG/e(B2e$B7ne(B5e$BF|e(B23:05 Yusuke ENDOH [email protected]:

e$B$=$l$r:,5r$Ke(B rubyspec [email protected]$7$?$N$O;d$J$N$G$A$g$C$H5$$^$:$$$G$9$,!"e(B
e$B%-%c%s%;%k$5$l$k$H$$$&$3$H$J$i:[email protected]$7$^$9!#e(B

e$B>e5-$rAw$C$F$+$i5$$,$D$-$^$7$?$,!"[email protected][email protected]$$$F$$$^$7$?!#e(B
e$B$9$_$^$;$s!u$"$j$,$H$&$4$6$$$^$9!#e(B

e$B$3$l$K$h$C$F!"e(Brubyspec e$B$N%(%i!<$O8=:_e(B 1
e$B$D$K$J$C$F$$$^$9!#e(B

$ ./ruby -rdelegate -e ’
d = SimpleDelegator.new([42, :hello])
d.freeze
p d.clone.frozen?

false

e$B>e5-$Ge(B true e$B$,4|BT$5$l$F$$$^$9!#e(B
e$B=EMWEY$ODc$=$&$J$N$G!";EMMJQ99$H$$$&$3$H$J$i$=$l$G9=$$$^$;$s!#e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:40330] Re: Bug #2679 rubyspec:
SimpleDelegator when frozen creates a frozen clone ERROR”
on Fri, 5 Feb 2010 23:05:03 +0900, Yusuke ENDOH [email protected]
writes:

|[email protected]$C$?$N$O!"e(B[ruby-core:26122] e$B$G!Ve(Bpublic method e$B$7$+e(B delegate
|e$B$7$J$$!W$H$$$&$^$D$b$H$5$s$NJ}?K$,<($5$l$F$$$k$?$a$G$9!#e(B
|e$B$=$l$r:,5r$Ke(B rubyspec [email protected]$7$?$N$O;d$J$N$G$A$g$C$H5$$^$:$$$G$9$,!“e(B
|e$B%-%c%s%;%k$5$l$k$H$$$&$3$H$J$i:[email protected]$7$^$9!#e(B
|
|e$B$^$D$b$H$5$s!”$I$&$7$^$9!)e(B

e$B$(!<$H!“JL7o$GMh=5A0H>$^$G$a$A$c$a$A$cK;$7$/$F$f$C$/$j9M$($ke(B
e$B;~4V$,$”$j$^$;$s!#[email protected][email protected]$b$^[email protected]%U%)%m!<$7$F$J$$$7!#e(B
e$B$H$$$&$o$1$G!"[email protected]$1;~4V$r$/[email protected]$5$$!#?eMK$+LZMKJU$j$+$i!"e(B
e$B$3$N7o$K$D$$$F??LLL$K8!F$$7$^$9!#e(B

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs