File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Expand file tree Collapse file tree 1 file changed +30
-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,35 @@ 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+ eval {
389+ sub helloworld { return $hw ; }
390+ my $rv = goto &helloworld;
391+ };
392+ like($@ , qr / ^Can't goto subroutine from an eval-block/ ,
393+ " Can't goto named subroutine from an eval block" );
394+
395+ eval {
396+ my $coderef = sub { return $hw ; };
397+ my $rv = goto &$coderef ;
398+ };
399+ like($@ , qr / ^Can't goto subroutine from an eval-block/ ,
400+ " Can't goto subroutine (&coderef) from an eval block" );
401+ }
402+
403+
404+
376405# Final test: ensure that we saw no deprecation warnings
377406# ... but rework this to count fatalizations once work is more developed
378407
You can’t perform that action at this time.
0 commit comments