cperl
cperl copied to clipboard
Deep recursion error from function that isn't even recursive
I get this failure in the Type-Tiny 1.010000 test suite:
Deep recursion on subroutine "Test::TypeTiny::should_fail" at t/20-unit/Types-Common-Numeric/ranges.t line 44.
But should_fail isn't a recursive function. It does do a goto \&Test::More::ok at the end after setting @_ so this could be a problem with cperl's tail call optimizations?
Oooh, additional information. should_fail is called all over the test suite, so I was curious why it was only this particular call that was dying.
Line 44 performs the 100th call of should_fail for ranges.t. The recursion limit is 100. So I guess it's thinking that these calls are recursive when they're really just repeated.
I can reproduce with this:
use strict;
use warnings FATAL => 'all';
use Test::More;
sub bar { goto \&Test::More::ok }
bar(1) for 1..101;
done_testing();
Further, Test::More::ok has a signature on cperl, though http://perl11.org/cperl/#Changed-calls-to-signatures seems to suggest that using goto would be the correct way to do a tail call to it.