summaryrefslogtreecommitdiffhomepage
path: root/src/codegen.c
diff options
context:
space:
mode:
authorMasamitsu MURASE <[email protected]>2013-01-06 06:23:10 +0900
committerMasamitsu MURASE <[email protected]>2013-01-06 06:23:10 +0900
commitd48bb813d8a4a7b1f1ea87f9187f231ff22af24a (patch)
treef6f37ece26d4bcf46daa6e46078e7d37c6648948 /src/codegen.c
parent749404051cadf750a37919c24550a6f9da44c2e5 (diff)
downloadmruby-d48bb813d8a4a7b1f1ea87f9187f231ff22af24a.tar.gz
mruby-d48bb813d8a4a7b1f1ea87f9187f231ff22af24a.zip
`unless` without `else` should return nil if the condition is true.
Diffstat (limited to 'src/codegen.c')
-rw-r--r--src/codegen.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/codegen.c b/src/codegen.c
index 0451bb996..c1a62320d 100644
--- a/src/codegen.c
+++ b/src/codegen.c
@@ -1099,8 +1099,12 @@ codegen(codegen_scope *s, node *tree, int val)
genop(s, MKOP_AsBx(OP_JMPNOT, cursp(), 0));
codegen(s, tree->cdr->car, val);
+ if (val && !(tree->cdr->car)) {
+ genop(s, MKOP_A(OP_LOADNIL, cursp()));
+ push();
+ }
if (e) {
- if (val && tree->cdr->car) pop();
+ if (val) pop();
pos2 = new_label(s);
genop(s, MKOP_sBx(OP_JMP, 0));
dispatch(s, pos1);