File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ BEGIN {
1010use v5.16;
1111use warnings;
1212use Config;
13- plan tests => 41 ;
13+ plan tests => 44 ;
1414
1515# Excerpts from 'perldoc -f goto' as of perl-5.40.1 (Aug 2025)
1616#
@@ -373,6 +373,39 @@ SKIP:
373373 is $fac -> (5), 120, ' recursion via goto __SUB__' ;
374374}
375375
376+ # GH 23811 goto &NAME where block evaluates to coderef
377+ {
378+ local $@ ;
379+ my $hw = ' hello world' ;
380+
381+ eval {
382+ my $coderef = sub { return $hw ; };
383+ my $rv = goto &{ 1; $coderef ; };
384+ };
385+ like($@ , qr / ^Can't goto subroutine from an eval-block/ ,
386+ " Can't goto subroutine (block which evaluates to coderef) from an eval block" );
387+
388+ undef $@ ;
389+
390+ eval {
391+ sub helloworld { return $hw ; }
392+ my $rv = goto &helloworld;
393+ };
394+ like($@ , qr / ^Can't goto subroutine from an eval-block/ ,
395+ " Can't goto named subroutine from an eval block" );
396+
397+ undef $@ ;
398+
399+ eval {
400+ my $coderef = sub { return $hw ; };
401+ my $rv = goto &$coderef ;
402+ };
403+ like($@ , qr / ^Can't goto subroutine from an eval-block/ ,
404+ " Can't goto subroutine (&coderef) from an eval block" );
405+ }
406+
407+
408+
376409# Final test: ensure that we saw no deprecation warnings
377410# ... but rework this to count fatalizations once work is more developed
378411
You can’t perform that action at this time.
0 commit comments