mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Return nil if argument of NODE_RETURN and NODE_NEXT is not specified.
This commit is contained in:
+11
-3
@@ -1571,15 +1571,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:
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user