Commit 0f896904 authored by Tomoyuki Sahara's avatar Tomoyuki Sahara

rollback stack before executing ensure clause.

parent 4b24ee18
...@@ -1219,9 +1219,9 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self) ...@@ -1219,9 +1219,9 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
while (ci[0].ridx == ci[-1].ridx) { while (ci[0].ridx == ci[-1].ridx) {
cipop(mrb); cipop(mrb);
ci = mrb->ci; ci = mrb->ci;
mrb->stack = mrb->stbase + ci[1].stackidx;
if (ci[1].acc < 0 && prev_jmp) { if (ci[1].acc < 0 && prev_jmp) {
mrb->jmp = prev_jmp; mrb->jmp = prev_jmp;
mrb->stack = mrb->stbase + ci[1].stackidx;
longjmp(*(jmp_buf*)mrb->jmp, 1); longjmp(*(jmp_buf*)mrb->jmp, 1);
} }
while (eidx > mrb->ci->eidx) { while (eidx > mrb->ci->eidx) {
......
...@@ -315,6 +315,33 @@ assert('Exception 18') do ...@@ -315,6 +315,33 @@ assert('Exception 18') do
end == 3 end == 3
end end
assert('Exception 19') do
class Class4Exception19
def a
r = @e = false
begin
b
rescue
r = self.z
end
[ r, @e ]
end
def b
begin
1 * "b"
ensure
@e = self.z
end
end
def z
true
end
end
Class4Exception19.new.a == [true, true]
end
assert('Exception#inspect without message') do assert('Exception#inspect without message') do
Exception.new.inspect Exception.new.inspect
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