Skip to content

Commit 0e943ce

Browse files
committed
Exercise one exception in pp_goto()
Reworked from recommendation by Tony Cook in GH #23964.
1 parent e79b820 commit 0e943ce

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

t/op/defer.t

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ BEGIN {
66
set_up_inc('../lib');
77
}
88

9-
plan 32;
9+
plan 33;
1010

1111
use feature 'defer';
1212
no warnings 'experimental::defer';
@@ -325,3 +325,22 @@ no warnings 'experimental::defer';
325325
"Got expected exception: last out of defer block");
326326
}
327327

328+
# [GH #23964]
329+
{
330+
use warnings;
331+
no warnings 'experimental::defer';
332+
use feature 'say';
333+
334+
eval {
335+
sub f { goto FOO; }
336+
sub g { defer { f() } }
337+
g();
338+
goto BAR;
339+
FOO: say "FOO";
340+
BAR: say "BAR";
341+
};
342+
like($@,
343+
qr/Can't \"goto\" out of a \"defer\" block/,
344+
"Got expected exception: can't goto out of defer block");
345+
}
346+

0 commit comments

Comments
 (0)