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) ...@@ -1571,15 +1571,20 @@ codegen(codegen_scope *s, node *tree, int val)
break; break;
case NODE_RETURN: case NODE_RETURN:
codegen(s, tree, VAL); if (tree) {
pop(); codegen(s, tree, VAL);
pop();
}
else {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
}
if (s->loop) { if (s->loop) {
genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_RETURN)); genop(s, MKOP_AB(OP_RETURN, cursp(), OP_R_RETURN));
} }
else { else {
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL); genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
} }
push(); if (val) push();
break; break;
case NODE_YIELD: case NODE_YIELD:
...@@ -1631,6 +1636,9 @@ codegen(codegen_scope *s, node *tree, int val) ...@@ -1631,6 +1636,9 @@ codegen(codegen_scope *s, node *tree, int val)
codegen(s, tree, VAL); codegen(s, tree, VAL);
pop(); pop();
} }
else {
genop(s, MKOP_A(OP_LOADNIL, cursp()));
}
genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL); genop_peep(s, MKOP_AB(OP_RETURN, cursp(), OP_R_NORMAL), NOVAL);
} }
if (val) push(); 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