summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-26 06:14:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-26 06:14:59 +0000
commitf4ca0739ecf00e9c50aaca55e0ecc5e33dd49284 (patch)
treec62dcb1a1d10abec183165d0d8afe6107c12392f /test/ruby
parent667c0a3a8caeaa96378f778ee2fbef1b51c3cd13 (diff)
compile.c: fix tailcall optimization
* compile.c (iseq_peephole_optimize): don't apply tailcall optimization to send/invokesuper instructions with blockiseq. This is a follow-up to the changes in r51903; blockiseq is now the third operand of send/invokesuper instructions. [ruby-core:73413] [Bug #12018] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_optimization.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb
index 2115fc8..8804931 100644
--- a/test/ruby/test_optimization.rb
+++ b/test/ruby/test_optimization.rb
@@ -275,6 +275,22 @@ class TestRubyOptimization < Test::Unit::TestCase
assert_equal(123, delay { 123 }.call, bug6901)
end
+ def just_yield
+ yield
+ end
+
+ def test_tailcall_inhibited_by_block
+ assert_separately([], <<~'end;')
+ def just_yield
+ yield
+ end
+ iseq = RubyVM::InstructionSequence
+ result = iseq.compile("just_yield {:ok}", __FILE__, __FILE__, __LINE__,
+ tailcall_optimization: true).eval
+ assert_equal(:ok, result)
+ end;
+ end
+
class Bug10557
def [](_)
block_given?