From f62f90367fc3bce6714e7c34cbd040e14e43fe07 Mon Sep 17 00:00:00 2001 From: wanabe Date: Sun, 6 Oct 2019 16:52:09 +0900 Subject: tailcall optimization again (#2528) This is follow up of r67315. --- test/ruby/test_optimization.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/ruby') 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? -- cgit v1.2.3