fixed wrong stack adjustment for ensure clauses; fix #3175

parent 0b8d8dd3
...@@ -1513,6 +1513,7 @@ RETRY_TRY_BLOCK: ...@@ -1513,6 +1513,7 @@ RETRY_TRY_BLOCK:
/* A B return R(A) (B=normal,in-block return/break) */ /* A B return R(A) (B=normal,in-block return/break) */
if (mrb->exc) { if (mrb->exc) {
mrb_callinfo *ci; mrb_callinfo *ci;
mrb_value *stk;
int eidx; int eidx;
L_RAISE: L_RAISE:
...@@ -1524,6 +1525,7 @@ RETRY_TRY_BLOCK: ...@@ -1524,6 +1525,7 @@ RETRY_TRY_BLOCK:
if (ci->ridx == 0) goto L_STOP; if (ci->ridx == 0) goto L_STOP;
goto L_RESCUE; goto L_RESCUE;
} }
stk = mrb->c->stack;
while (ci[0].ridx == ci[-1].ridx) { while (ci[0].ridx == ci[-1].ridx) {
cipop(mrb); cipop(mrb);
ci = mrb->c->ci; ci = mrb->c->ci;
...@@ -1533,6 +1535,7 @@ RETRY_TRY_BLOCK: ...@@ -1533,6 +1535,7 @@ RETRY_TRY_BLOCK:
MRB_THROW(prev_jmp); MRB_THROW(prev_jmp);
} }
if (ci == mrb->c->cibase) { if (ci == mrb->c->cibase) {
mrb->c->stack = stk;
while (eidx > 0) { while (eidx > 0) {
ecall(mrb, --eidx); ecall(mrb, --eidx);
} }
......
...@@ -338,10 +338,13 @@ assert('Exception 19') do ...@@ -338,10 +338,13 @@ assert('Exception 19') do
begin begin
1 * "b" 1 * "b"
ensure ensure
@e = self.z @e = self.zz
end end
end end
def zz
true
end
def z def z
true true
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment