summaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-09 18:38:41 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-09 18:38:41 +0000
commita5e2f3221a96ee54dd8f5abdfc4439328f34e386 (patch)
treef0a4041a0fd9c99870cb0a596e234f121274a783 /compile.c
parent62efc6f305045d83eab8493bc3b58e9bd3504159 (diff)
* compile.c (compile_array_): modify wrong optimization.
A script "[print(1)]; print(2)" should output "12". However, the compiler had eliminted "[print(1)]" expression because it is void expression (unused array). Of course, side-effect should be remained. This issue is reported by Masaya Tarui. * bootstraptest/test_literal.rb: add a test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/compile.c b/compile.c
index 21bb780ddb..5e0b61572e 100644
--- a/compile.c
+++ b/compile.c
@@ -2435,6 +2435,7 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
else {
ADD_INSN(anchor, line, concatarray);
}
+
APPEND_LIST(ret, anchor);
break;
case COMPILE_ARRAY_TYPE_HASH:
@@ -2461,6 +2462,10 @@ compile_array_(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE* node_root,
break;
}
}
+ else {
+ /* poped */
+ APPEND_LIST(ret, anchor);
+ }
}
}
}