mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1184 from iij/pr-ensure-on-correct-stack
Rollback stack before executing ensure clause.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user