Hello,

2011/6/6 Rodrigo Rosenfeld Rosas <rr.rosas / gmail.com>:
> I have a situation where there is some code in Gitorious like:
>
> unless defined? GitoriousConfig
> =A0# tons of lines here
> end
>
> And I would it to look like
>
> return if defined? GitoriousConfig
>
> #tons of lines here
>
> It would be great to allow return from a required file or some other keyw=
ord (break, etc or a new one)


Agreed.  It would be also useful to write platform-specific code:

  require "test/unit"

  return unless /mswin|cygwin|mingw|bccwin/ =3D~ RUBY_PLATFORM

  class TestForWindowsEnv < Test::Unit::TestCase
  ...


Here is an experimental patch:


diff --git a/compile.c b/compile.c
index 10d63bc..7b9c490 100644
--- a/compile.c
+++ b/compile.c
@@ -4291,10 +4291,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR
*ret, NODE * node, int poped)
 	rb_iseq_t *is =3D iseq;

 	if (is) {
-	    if (is->type =3D=3D ISEQ_TYPE_TOP) {
-		COMPILE_ERROR((ERROR_ARGS "Invalid return"));
-	    }
-	    else {
 		LABEL *splabel =3D 0;

 		if (is->type =3D=3D ISEQ_TYPE_METHOD) {
@@ -4321,7 +4317,6 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR
*ret, NODE * node, int poped)
 			ADD_INSN(ret, nd_line(node), pop);
 		    }
 		}
-	    }
 	}
 	break;
       }
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index f40dfdf..274f45d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1561,8 +1561,6 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp=
,
 		    cfp =3D RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp);
 		}

-		rb_vm_localjump_error("unexpected return", throwobj, TAG_RETURN);
-
 	      valid_return:
 		pt =3D dfp;
 	    }

--=20
Yusuke Endoh <mame / tsg.ne.jp>