diff options
author | wanabe <s.wanabe@gmail.com> | 2019-10-25 04:40:39 +0900 |
---|---|---|
committer | Koichi Sasada <ko1@atdot.net> | 2019-10-25 04:40:39 +0900 |
commit | 4ff2c58f919153b9a47f69f855a0b9d2bb0e0bbe (patch) | |
tree | 04b08b1dee23fb5073ba69ae851101dd1c69e32b /test | |
parent | 58b363bf0d1f31ae9bcbaf301f9abedb99fa90f6 (diff) |
retry tailcall optimization (#2529)
Sorry, f62f90367fc3bce6714e7c34cbd040e14e43fe07 is push miss.
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_optimization.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/test/ruby/test_optimization.rb b/test/ruby/test_optimization.rb index 6a9e9601f4..2b18c4aa59 100644 --- a/test/ruby/test_optimization.rb +++ b/test/ruby/test_optimization.rb @@ -451,6 +451,21 @@ class TestRubyOptimization < Test::Unit::TestCase } end + def test_tailcall_not_to_grow_stack + bug16161 = '[ruby-core:94881]' + + tailcall("#{<<-"begin;"}\n#{<<~"end;"}") + begin; + def foo(n) + return :ok if n < 1 + foo(n - 1) + end + end; + assert_nothing_raised(SystemStackError, bug16161) do + assert_equal(:ok, foo(1_000_000), bug16161) + end + end + class Bug10557 def [](_) block_given? |