diff options
| author | Masamitsu MURASE <[email protected]> | 2013-02-27 02:37:26 +0900 |
|---|---|---|
| committer | Masamitsu MURASE <[email protected]> | 2013-02-27 03:45:11 +0900 |
| commit | 49c929a237fe482b2286aab47a263f8b51225cad (patch) | |
| tree | e75a3886340cc2497248b7b22b1d6ba52b9dcfcc | |
| parent | d3418a7ac8cf6a98da6572a169ce3aeaf7d93c35 (diff) | |
| download | mruby-49c929a237fe482b2286aab47a263f8b51225cad.tar.gz mruby-49c929a237fe482b2286aab47a263f8b51225cad.zip | |
Return nil if argument of NODE_RETURN and NODE_NEXT is not specified.
| -rw-r--r-- | src/codegen.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/codegen.c b/src/codegen.c index 53324f321..a595a27c8 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -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(); |
