From a5e2f3221a96ee54dd8f5abdfc4439328f34e386 Mon Sep 17 00:00:00 2001 From: ko1 Date: Wed, 9 Jan 2013 18:38:41 +0000 Subject: * 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 --- bootstraptest/test_literal.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bootstraptest/test_literal.rb') diff --git a/bootstraptest/test_literal.rb b/bootstraptest/test_literal.rb index 5a9497c642..b95a2f2d0a 100644 --- a/bootstraptest/test_literal.rb +++ b/bootstraptest/test_literal.rb @@ -224,3 +224,8 @@ assert_equal 'ok', %q{ # long hash literal (optimized) eval "a = {#{(1..10_000).map{|n| "#{n} => #{n}"}.join(', ')}}" :ok } + +assert_equal 'ok', %q{ + [print(:ok), exit] # void literal with side-effect + :dummy +} -- cgit v1.2.3