[Bug #2402] super in instance_eval

Bug #2402: super in instance_eval
http://redmine.ruby-lang.org/issues/show/2402

e$B5/I<<Te(B: Shugo M.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
ruby -v: ruby 1.9.2dev (2009-11-24 trunk 25909) [i686-linux]

instance_evale$B$N%V%m%C%/Fb$Ge(Bsupere$B$r8F$V$H!"e(Binstance_evale$B$GJQ99$5$l$?e(B
selfe$B$KBP$7$Fe(Bsupere$B$N8F$S=P$7$r9T$C$F$7$^$&$h$&$G$9!#e(B

defiant:build$ cat t.rb
class Foo
def foo
p self
end
end

class Bar < Foo
def foo
x = Object.new
x.instance_eval do
super
end
end
end

Bar.new.foo
defiant:build$ ./ruby-trunk.1124 -v t.rb
ruby 1.9.2dev (2009-11-24 trunk 25909) [i686-linux]
#Object:0x8590f6c

Foo#fooe$B$,8F$P$l$k$N$Ke(Bselfe$B$,e(BObjecte$B$H$$$&!“$A$g$C$H$*$+$7$J$3$H$K$J$C$F$$$^$9!#e(B
e$B$A$g$C$H<+?.$,$”$j$^$;$s$,!"0l1~%Q%C%A$rE:IU$7$^$9!#e(B

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

e$BFC0[%/%i%9Dj5A$Ge(Bsupere$B$7$?;~$Oe(BNoMethodErrore$B$K$J$k$h$&$G$9!#e(B

defiant:build$ cat t2.rb
class Foo
def foo
p self
end
end

class Bar < Foo
def foo
x = Object.new
class << x
super
end
end
end

Bar.new.foo
defiant:build$ ./ruby-trunk.1124 -v t2.rb
ruby 1.9.2dev (2009-11-24 trunk 25909) [i686-linux]
t2.rb:11:in singletonclass': super called outside of method (NoMethodError) from t2.rb:10:in foo’
from t2.rb:16:in `’

1.8e$B$G$Oe(BFoo#fooe$B$,8F$P$l$^$9!#e(B

defiant:build$ ruby-1_8 -v t2.rb
ruby 1.8.8dev (2009-10-22 revision 25430) [i686-linux]
#Bar:0xb7ea443c

e$B;29M$^$G$KB>$N=hM}7O$G$O0J2<$N$h$&$J5sF0$G$7$?!#e(B

defiant:build$ ir -v t2.rb
IronRuby 0.9.1.0 on .NET 2.0.0.0
#Bar:0x0000056
defiant:build$ jruby -v t2.rb
jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2009-11-12 421150b) (Java
HotSpot™ Client VM 1.6.0_16) [i386-java]
#<Class:#Object:0x180cf2a>
defiant:build$ rbx -v t2.rb
rubinius 0.13.0-dev (1.8.7 e614007b 2009-11-06) [i686-pc-linux-gnu]
An exception occurred running t2.rb
No method ‘bytecode’ on an instance of NilClass. (NoMethodError)

e$B$=$l$>$l8D@-$,$"$C$FLLGr$$$G$9$M!#e(B

e$B8D?ME*$K$ONc30$G$b$$$$$s$8$c$J$$$+$J$H;W$$$^$9$,!"e(B1.9e$B$Ne(Binstance_evale$B$G$Ne(B
supere$B$d!"e(BJRubye$B$NFC0[%/%i%9Dj5A$G$Ne(Bsupere$B$N$h$&$K!"JQ$J%l%7!<%P$Ge(Bsupere$B$,e(B
e$B8F$P$l$F$7$^$&$N$O$^$:$$$s$8$c$J$$$+$H;W$$$^$9!#e(B

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

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

e$BC4Ev<Te(B Yukihiro M.e$B$+$ie(BKoichi Sasadae$B$KJQ99e(B

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

instance_evale$B$N%V%m%C%/Fb$Ge(Bsupere$B$r8F$V$H!"e(Binstance_evale$B$GJQ99$5$l$?e(B
selfe$B$KBP$7$Fe(Bsupere$B$N8F$S=P$7$r9T$C$F$7$^$&$h$&$G$9!#e(B

e$B:F8=$7$^$7$?!#0J2<$Ge(B SEGV e$B$9$k$3$H$b3NG’$7$^$7$?!#e(B

class MyArray < Array
def reverse
“foo”.instance_eval do
super
end
end
end
MyArray.new([1,2,3]).reverse

e$B%Q%C%A$b8+$^$7$?!#B.EYNt2=$O5$$K$J$j$^$9$,!"@5$7$$$H;W$$$^$9!#e(B

vm_search_superclass e$B$rDI$C$F$$?$H$3$m!"e(Brecv
e$B$,I,MW$K$J$k$N$O!"e(B
e$B8=:
$N%3%s%F%-%9%H$,e(B include e$B$5$l$?e(B module
e$B$K=jB0$9$k%a%=%C%I$Ne(B
e$B>l9ge(B (ICLASS) e$B$@$1$N$h$&$G$9$N$G!"$=$N;~$^$Ge(B recv
e$B$NF1Dj$rCY1de(B
e$B$5$;$k$H!"B.EYNt2=$b5$$K$J$i$J$/$J$k$+$b$H;W$$$^$9!#e(B

e$B$?$@!“$=$NJU$N=$@5$Oe(B [ruby-dev:40959]
e$B$N=$@5$N8e$K$d$C$?$[$&$,e(B
e$B$$$$M=46$,$9$k$N$G!”:GE,2=$O8e$K$7$F!“$H$j$”$($:$3$NLdBj$OA0EDe(B
e$B$5$s$N%Q%C%A$Ge(B close e$B$9$k$N$,$$$$$H;W$$$^$9!#e(B


Yusuke E. [email protected]

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

e$B%A%1%C%He(B #2402 e$B$,99?7$5$l$^$7$?!#e(B (by Koichi Sasada)

e$B%Q%C%A$OA4A38+$F$J$$$N$G$9$,!$1sF#$5$s$,NI$$$H6D$C$F$k$N$GNI$$$N$G$O$J$$$+$H;W$$$^$9!%e(B

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

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

Target version 1.9.xe$B$K%;%C%He(B

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

[Bug #2502] [Bug #3136] e$B$"$?$j$Ge(B super
e$B$N=$@5$O8e2s$7$K$7$h$&$H$$$&$3$H$Ke(B
e$B$J$j!“e(Br28043 e$B$G$H$j$”$($:$NBP:v$r$7$?$N$G!"e(B1.9.x
e$B$K$7$^$9!#e(B


Yusuke E. [email protected]

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