return_from_class_frame.patch

Kazuki Tsujimoto, 05/05/2011 02:02 PM

Download (1.56 KB)

View differences:

vm_insnhelper.c
1527 1527
		rb_control_frame_t *cfp = GET_CFP();
1528 1528
		VALUE *dfp = GET_DFP();
1529 1529
		VALUE *lfp = GET_LFP();
1530
		int in_class_frame = 0;
1530 1531

  
1531 1532
		/* check orphan and get dfp */
1532 1533
		while ((VALUE *) cfp < th->stack + th->stack_size) {
......
1534 1535
			lfp = cfp->lfp;
1535 1536
		    }
1536 1537
		    if (cfp->dfp == lfp && cfp->iseq->type == ISEQ_TYPE_CLASS) {
1538
			in_class_frame = 1;
1537 1539
			lfp = 0;
1538 1540
		    }
1539 1541

  
......
1541 1543
			if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_LAMBDA) {
1542 1544
			    VALUE *tdfp = dfp;
1543 1545

  
1546
			    if (in_class_frame) {
1547
				/* lambda {class A; ... return ...; end} */
1548
				dfp = cfp->dfp;
1549
				goto valid_return;
1550
			    }
1551

  
1544 1552
			    while (lfp != tdfp) {
1545 1553
				if (cfp->dfp == tdfp) {
1546 1554
				    /* in lambda */
bootstraptest/test_proc.rb
429 429
  raise "ok"
430 430
}
431 431

  
432
assert_equal 'ok', %q{
433
  lambda do
434
    class A
435
      class B
436
        proc{return :ng}.call
437
      end
438
    end
439
  end.call
440
  :ok
441
}
442

  
443
assert_equal 'ok', %q{
444
  $proc = proc{return}
445
  begin
446
    lambda do
447
      class A
448
        class B
449
          $proc.call
450
        end
451
      end
452
    end.call
453
    :ng
454
  rescue LocalJumpError
455
    :ok
456
  end
457
}