summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 4fdeeb2e6e..d41e61322d 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1080,6 +1080,7 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
const VALUE *current_ep = GET_EP();
const VALUE *target_lep = VM_EP_LEP(current_ep);
int in_class_frame = 0;
+ int toplevel = 1;
escape_cfp = reg_cfp;
while (escape_cfp < eocfp) {
@@ -1098,6 +1099,7 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
if (lep == target_lep) {
if (VM_FRAME_TYPE(escape_cfp) == VM_FRAME_MAGIC_LAMBDA) {
+ toplevel = 0;
if (in_class_frame) {
/* lambda {class A; ... return ...; end} */
goto valid_return;
@@ -1114,6 +1116,20 @@ vm_throw_start(rb_thread_t *const th, rb_control_frame_t *const reg_cfp, enum ru
}
}
}
+ else if (VM_FRAME_RUBYFRAME_P(escape_cfp)) {
+ switch (escape_cfp->iseq->body->type) {
+ case ISEQ_TYPE_TOP:
+ case ISEQ_TYPE_MAIN:
+ if (toplevel) goto valid_return;
+ break;
+ case ISEQ_TYPE_EVAL:
+ case ISEQ_TYPE_CLASS:
+ toplevel = 0;
+ break;
+ default:
+ break;
+ }
+ }
}
if (escape_cfp->ep == target_lep && escape_cfp->iseq->body->type == ISEQ_TYPE_METHOD) {