diff --git a/t/op/goto-sub.t b/t/op/goto-sub.t index d32b18b48d47..83b86493586f 100644 --- a/t/op/goto-sub.t +++ b/t/op/goto-sub.t @@ -7,10 +7,10 @@ BEGIN { require './charset_tools.pl'; } +use v5.16; use warnings; -use strict; use Config; -plan tests => 40; +plan tests => 41; # Excerpts from 'perldoc -f goto' as of perl-5.40.1 (Aug 2025) # @@ -61,7 +61,7 @@ our $foo; sub f1 { my $x; - goto sub { $x=0; ok(1,"don't prematurely free CV\n") } + goto sub { $x=0; ok(1, "don't prematurely free CV"); }; } f1(); @@ -358,6 +358,21 @@ SKIP: } +# GH 23804 goto __SUB__ +{ + my $fac = sub { + unshift @_, 1; + goto sub { + my ($acc, $i) = @_; + return $acc if $i < 2; + @_ = ($acc * $i, $i - 1); + goto __SUB__; + }; + }; + + is $fac->(5), 120, 'recursion via goto __SUB__'; +} + # Final test: ensure that we saw no deprecation warnings # ... but rework this to count fatalizations once work is more developed