Commit ced8fea3 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #898 from masamitsu-murase/modify_return_value

Modify handling of NODE_RETURN and NODE_NEXT.
parents 2a932441 f413e688
......@@ -1570,15 +1570,20 @@ codegen(codegen_scope *s, node *tree, int val)
break;
case NODE_RETURN:
codegen(s, tree, VAL);
pop();
if (tree) {
codegen(s, tree, VAL);
pop();
}
else {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
}
if (s->loop) {
genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_RETURN));
}
else {
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
}
push();
if (val) push();
break;
case NODE_YIELD:
......@@ -1630,6 +1635,9 @@ codegen(codegen_scope *s, node *tree, int val)
codegen(s, tree, VAL);
pop();
}
else {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
}
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
}
if (val) push();
......
......@@ -321,19 +321,19 @@ end
# very deeply recursive function that stil returns albeit very deeply so
$test_infinite_recursion = 0
TEST_INFINITE_RECURSION_MAX = 100000
TEST_INFINITE_RECURSION_MAX = 1000000
def test_infinite_recursion
$test_infinite_recursion += 1
if $test_infinite_recursion > TEST_INFINITE_RECURSION_MAX
return $test_infinite_recursion
return $test_infinite_recursion
end
test_infinite_recursion
test_infinite_recursion
end
assert('Infinite recursion should result in an exception being raised') do
a = begin
a = begin
test_infinite_recursion
rescue
rescue
:ok
end
# OK if an exception was caught, otherwise a number will be stored in a
......
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