[Bug #2657] rubyspec: The return keyword within define_method goes through the method via a closure

Bug #2657: rubyspec: The return keyword within define_method goes
through the method via a closure FAILED
http://redmine.ruby-lang.org/issues/show/2657

e$B5/I<<Te(B: Yusuke E.
e$B%9%F!<%?%9e(B: Open, e$BM%@hEYe(B: Normal
e$BC4Ev<Te(B: Koichi Sasada, e$B%+%F%4%je(B: core, Target version: 1.9.x
ruby -v: ruby 1.9.2dev (2010-01-26 trunk 26420) [i686-linux]

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

rubyspec e$B$N0J2<$N%(%i!<$rD4$Y$F$_$^$7$?!#e(B

The return keyword within define_method goes through the method via a
closure FAILED
Expected :bad
to equal :good

/home/mame/work/ruby/spec/rubyspec/language/return_spec.rb:269:in
block (3 levels) in <top (required)>' /home/mame/work/ruby/spec/rubyspec/language/return_spec.rb:4:in<top
(required)>’

e$B!{LdBje(B

$ ./ruby -e ’
class C
define_method(:foo) do |&x|
x.call
end
def outer
foo { return :good }
return :bad
end
end
p C.new.outer

ok
:bad

e$B$H$$$&%W%m%0%i%`$,!"e(B:good e$B$G$J$/e(B :bad
e$B$rI=<($7$F$7$^$$$^$9!#$D$$$G$Ke(B
e$BFf$Ne(B ok e$B$b=P$F$$$^$9!#e(B

1.8 e$B$G$Oe(B :good e$B$,=P$^$9$7!"e(Bdefine_method e$B$re(B def
e$B$KCV$-49$($k$He(B 1.9 e$B$G$be(B
:good e$B$,=P$^$9$N$G!"e(B:good e$B$H=P$k$N$,@5$7$=$&$G$9!#e(B

e$B!{860xe(B

rb_vm_invoke_proc e$B$NCf$Ge(B lambda e$B$NCf$Ne(B TAG_RETURN
e$B$r;_$a$F$7$^$&$3$H$,e(B
e$B860x$G$9!#e(B

e$B$3$N=hM}$O0l8+$9$k$H!"!Ve(Blambda e$BCf$Ne(B return e$B$,e(B lambda
e$B$G;$^$k$?$a$Ke(B
e$BI,MW!W$H;W$C$F$7$^$$$^$9$,!"e(BTAG_RETURN e$B$OIaDL$Ke(B vm_exec
e$B$NCf$G=hM}$5$le(B
goto finish_vme; e$B$K$h$C$F;
$a$i$l$^$9$N$G!"[email protected]$H;W$o$l$^$9!#e(B

e$B$3$N=hM}$,ITMW$G$"$k$3$H$N>u67>Z5r$H$7$F!"e(B

  • e$B$3$N=hM}$r>C$7$F$b%F%9%H$N%(%i!<$OA}$($J$$e(B (e$B>e5-$Ne(B
    rubyspec e$B$NJ,8:$ke(B)

  • e$B%+%P%l%C%8$r8+$F$b!">e5-$Ne(B rubyspec
    e$B$N%F%9%H0J30$G$O<B9T$5$l$F$$$J$$e(B
    (http://dame.dyndns.org:7001/20100126/ruby/vm.c e$B$Ne(B
    rb_vm_invoke_proc
    e$B$NCf$N$3$N%A%’%C%/$N%+%P%l%C%8$,e(B 1 [email protected]$1e(B)

  • e$B$3$N=hM}$K$O%G%P%C%0MQ$Ne(B printf e$BJ8$,;D$C$F$$$ke(B (2008-06-17
    e$B$Ne(B r17390
    e$B$+$i$:$C$He(B) e$B$N$K!"IaDL$Ke(B lambda { return }.call
    e$B$J$I$7$F$b=P2q$o$J$$e(B

e$B$H$$$&$o$1$G!“Ev;~$OI,[email protected]$C$?$N$+$b$7$l$^$;$s$,!”>/$J$/$H$b8=:_$G$Oe(B
e$B$3$N=hM}$O32$G$7$+$J$$$H;W$$$^$9!#e(B

e$B!{%Q%C%Ae(B

e$BLdBj$N=hM}$r>C$7$^$9!#e(B

diff --git a/vm.c b/vm.c
index bb19ecb…f03cf31 100644
— a/vm.c
+++ b/vm.c
@@ -609,21 +609,6 @@ rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc,
VALUE self,
}

 if (state) {
  • if (state == TAG_RETURN && proc->is_lambda) {
  •  VALUE err = th->errinfo;
    
  •  VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(err);
    
  •  if (escape_dfp == cfp->dfp) {
    
  • printf(“ok\n”);
  • state = 0;
  • th->errinfo = Qnil;
  • th->cfp = cfp;
  • val = GET_THROWOBJ_VAL(err);
  •  }
    
  • }
  • }
  • if (state) {
    JUMP_TAG(state);
    }
    return val;


Yusuke ENDOH [email protected]

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

(2010/01/26 19:59), Yusuke E. wrote::

e$B$3$N=hM}$O32$G$7$+$J$$$H;W$$$^$9!#e(B
e$B!!$O$$!%6D$kDL$j$+$H;W$$$^$9!%[email protected]$7$F2<$5$$$^$;!%e(B

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

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 r26425.
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/2657

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