summaryrefslogtreecommitdiff
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-10 09:04:44 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-07-10 09:04:44 +0000
commit9cf9d5eaf7923498a3ece7f6757c9010aaa55e71 (patch)
treed7793be0098c6b916351a42a6f7bbed1bccb04ff /vm_insnhelper.c
parentb9a13f4962333f08338b9839d1bd9151665ac8aa (diff)
* vm_insnhelper.c (vm_throw): check a class frame.
Fixes Bug #4648. The patch is contributed by Kazuki Tsujimoto. * bootstraptest/test_proc.rb: add tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 10f76ca8d7..c7782149b8 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1541,6 +1541,7 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
rb_control_frame_t *cfp = GET_CFP();
VALUE *dfp = GET_DFP();
VALUE *lfp = GET_LFP();
+ int in_class_frame = 0;
/* check orphan and get dfp */
while ((VALUE *) cfp < th->stack + th->stack_size) {
@@ -1548,6 +1549,7 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
lfp = cfp->lfp;
}
if (cfp->dfp == lfp && cfp->iseq->type == ISEQ_TYPE_CLASS) {
+ in_class_frame = 1;
lfp = 0;
}
@@ -1555,6 +1557,12 @@ vm_throw(rb_thread_t *th, rb_control_frame_t *reg_cfp,
if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA) {
VALUE *tdfp = dfp;
+ if (in_class_frame) {
+ /* lambda {class A; ... return ...; end} */
+ dfp = cfp->dfp;
+ goto valid_return;
+ }
+
while (lfp != tdfp) {
if (cfp->dfp == tdfp) {
/* in lambda */