Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3250,6 +3250,7 @@ PP(pp_goto)
I32 ix;
PERL_CONTEXT *cx;
OP *enterops[GOTO_DEPTH];
bool into_construct = FALSE;
const char *label = NULL;
STRLEN label_len = 0;
U32 label_flags = 0;
Expand Down Expand Up @@ -3652,9 +3653,7 @@ PP(pp_goto)
? 2
: 1;
if (enterops[i])
deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT,
"5.42",
"Use of \"goto\" to jump into a construct");
into_construct = TRUE;
}

/* pop unwanted frames */
Expand Down Expand Up @@ -3686,6 +3685,12 @@ PP(pp_goto)
}
}

if (into_construct)
deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT,
"5.42",
"Use of \"goto\" to jump into a construct");


if (do_dump) {
#ifdef VMS
if (!retop) retop = PL_main_start;
Expand Down
17 changes: 6 additions & 11 deletions t/lib/croak/pp_ctl
Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
__END__
# NAME goto into foreach
no warnings 'deprecated';
goto f;
foreach(1){f:}
EXPECT
Can't "goto" into the middle of a foreach loop at - line 3.
Can't "goto" into the middle of a foreach loop at - line 2.
########
# NAME goto into given
no warnings 'deprecated';
goto f;
CORE::given(1){f:}
EXPECT
Can't "goto" into a "given" block at - line 3.
Can't "goto" into a "given" block at - line 2.
########
# NAME goto from given topic expression
no warnings 'deprecated';
CORE::given(goto f){f:}
EXPECT
Can't "goto" into a "given" block at - line 2.
Can't "goto" into a "given" block at - line 1.
########
# NAME goto into expression
no warnings 'deprecated';
eval { goto a; 1 + do { a: } }; warn $@;
eval { goto b; meth { b: } }; warn $@;
eval { goto c; map { c: } () }; warn $@;
eval { goto d; f(do { d: }) }; die $@;
EXPECT
Can't "goto" into a binary or list expression at - line 1.
Can't "goto" into a binary or list expression at - line 2.
Can't "goto" into a binary or list expression at - line 3.
Can't "goto" into a binary or list expression at - line 4.
Can't "goto" into a binary or list expression at - line 5.
########
# NAME dump with computed label
no warnings 'deprecated';
my $label = "foo";
CORE::dump $label;
EXPECT
Can't find label foo at - line 3.
Can't find label foo at - line 2.
########
# NAME when outside given
use 5.01; no warnings 'deprecated';
use 5.01;
when(undef){}
EXPECT
Can't "when" outside a topicalizer at - line 2.
Expand Down
Loading