diff options
author | wanabe <s.wanabe@gmail.com> | 2019-10-06 16:52:09 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-10-06 16:52:09 +0900 |
commit | f62f90367fc3bce6714e7c34cbd040e14e43fe07 (patch) | |
tree | 3aefe411a803886588329f0ed6d728fac26ff734 /test/ruby | |
parent | 6525d3bcc7d0be65e2ff97d6785d9f36b5e4988a (diff) | |
download | ruby-f62f90367fc3bce6714e7c34cbd040e14e43fe07.tar.gz |
tailcall optimization again (#2528)
This is follow up of r67315.
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_optimization.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 6a9e9601f4..0d4f69240e 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -451,6 +451,19 @@ class TestRubyOptimization < Test::Unit::TestCase } end + def test_tailcall_not_to_grow_stack + bug16161 = '[ruby-core:94881]' + + tailcall("#{<<-"begin;"}\n#{<<~"end;"}") + begin; + def sum(n, s = 0) + return s if n < 1 + sum(n - 1, n + s) + end + end; + assert_equal(0, sum(1_000_000).to_s.size, message(bug16161) {disasm(:fact_helper)}) + end + class Bug10557 def [](_) block_given? |