Commit 0629cf21 authored by Kazuki Tsujimoto's avatar Kazuki Tsujimoto

A rescue clause with no parameter list rescues only StandardErrors

parent 597978c1
...@@ -834,14 +834,18 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -834,14 +834,18 @@ codegen(codegen_scope *s, node *tree, int val)
push(); push();
while (n2) { while (n2) {
node *n3 = n2->car; node *n3 = n2->car;
if (pos1) dispatch(s, pos1);
if (n3->car) {
node *n4 = n3->car; node *n4 = n3->car;
if (pos1) dispatch(s, pos1);
pos2 = 0; pos2 = 0;
while (n4) { do {
if (n4) {
codegen(s, n4->car, VAL); codegen(s, n4->car, VAL);
}
else {
genop(s, MKOP_ABx(OP_GETCONST, cursp(), new_msym(s, mrb_intern(s->mrb, "StandardError"))));
push();
}
genop(s, MKOP_AB(OP_MOVE, cursp(), exc)); genop(s, MKOP_AB(OP_MOVE, cursp(), exc));
push(); push();
genop(s, MKOP_A(OP_LOADNIL, cursp())); genop(s, MKOP_A(OP_LOADNIL, cursp()));
...@@ -850,12 +854,14 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -850,12 +854,14 @@ codegen(codegen_scope *s, node *tree, int val)
tmp = new_label(s); tmp = new_label(s);
genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2)); genop(s, MKOP_AsBx(OP_JMPIF, cursp(), pos2));
pos2 = tmp; pos2 = tmp;
if (n4) {
n4 = n4->cdr; n4 = n4->cdr;
} }
} while (n4);
pos1 = new_label(s); pos1 = new_label(s);
genop(s, MKOP_Bx(OP_JMP, 0)); genop(s, MKOP_Bx(OP_JMP, 0));
dispatch_linked(s, pos2); dispatch_linked(s, pos2);
}
pop(); pop();
if (n3->cdr->car) { if (n3->cdr->car) {
gen_assignment(s, n3->cdr->car, exc, NOVAL); gen_assignment(s, n3->cdr->car, exc, NOVAL);
......
...@@ -193,3 +193,39 @@ assert('Exception 10') do ...@@ -193,3 +193,39 @@ assert('Exception 10') do
7+7 7+7
end == 12 end == 12
end end
assert('Exception 11') do
a = :ok
begin
begin
raise Exception
rescue
a = :ng
end
rescue Exception
end
a == :ok
end
assert('Exception 12') do
a = :ok
begin
raise Exception rescue a = :ng
rescue Exception
end
a == :ok
end
assert('Exception 13') do
a = :ng
begin
raise StandardError
rescue TypeError, ArgumentError
a = :ng
rescue
a = :ok
else
a = :ng
end
a == :ok
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