Commit 49c929a2 authored by Masamitsu MURASE's avatar Masamitsu MURASE

Return nil if argument of NODE_RETURN and NODE_NEXT is not specified.

parent d3418a7a
......@@ -1571,15 +1571,20 @@ codegen(codegen_scope *s, node *tree, int val)
break;
case NODE_RETURN:
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:
......@@ -1631,6 +1636,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();
......
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