Merge pull request #1184 from iij/pr-ensure-on-correct-stack

Rollback stack before executing ensure clause.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2013-04-17 02:46:17 -07:00
2 changed files with 28 additions and 1 deletions
+1 -1
View File
@@ -1219,9 +1219,9 @@ mrb_run(mrb_state *mrb, struct RProc *proc, mrb_value self)
while (ci[0].ridx == ci[-1].ridx) {
cipop(mrb);
ci = mrb->ci;
mrb->stack = mrb->stbase + ci[1].stackidx;
if (ci[1].acc < 0 && prev_jmp) {
mrb->jmp = prev_jmp;
mrb->stack = mrb->stbase + ci[1].stackidx;
longjmp(*(jmp_buf*)mrb->jmp, 1);
}
while (eidx > mrb->ci->eidx) {
+27
View File
@@ -315,6 +315,33 @@ assert('Exception 18') do
end == 3
end
assert('Exception 19') do
class Class4Exception19
def a
r = @e = false
begin
b
rescue TypeError
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
Exception.new.inspect
end