Skip to content

Commit f7c2444

Browse files
wolfsagejkeenan
authored andcommitted
Don't warn about jumping into a construct if we're DIE-ing
There are many cases where we throw exceptions if you attempt to goto somewhere you have no business going. We'd *also* throw a deprecation warning in these cases, which just seems silly. Deprecated means "this will stop working eventually", so there's no need to throw that when we're just going to die right now.
1 parent 9bb0c18 commit f7c2444

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

pp_ctl.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,6 +3250,7 @@ PP(pp_goto)
32503250
I32 ix;
32513251
PERL_CONTEXT *cx;
32523252
OP *enterops[GOTO_DEPTH];
3253+
bool into_construct = FALSE;
32533254
const char *label = NULL;
32543255
STRLEN label_len = 0;
32553256
U32 label_flags = 0;
@@ -3652,9 +3653,7 @@ PP(pp_goto)
36523653
? 2
36533654
: 1;
36543655
if (enterops[i])
3655-
deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT,
3656-
"5.42",
3657-
"Use of \"goto\" to jump into a construct");
3656+
into_construct = TRUE;
36583657
}
36593658

36603659
/* pop unwanted frames */
@@ -3686,6 +3685,12 @@ PP(pp_goto)
36863685
}
36873686
}
36883687

3688+
if (into_construct)
3689+
deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT,
3690+
"5.42",
3691+
"Use of \"goto\" to jump into a construct");
3692+
3693+
36893694
if (do_dump) {
36903695
#ifdef VMS
36913696
if (!retop) retop = PL_main_start;

t/lib/croak/pp_ctl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
__END__
22
# NAME goto into foreach
3-
no warnings 'deprecated';
43
goto f;
54
foreach(1){f:}
65
EXPECT
7-
Can't "goto" into the middle of a foreach loop at - line 3.
6+
Can't "goto" into the middle of a foreach loop at - line 2.
87
########
98
# NAME goto into given
10-
no warnings 'deprecated';
119
goto f;
1210
CORE::given(1){f:}
1311
EXPECT
14-
Can't "goto" into a "given" block at - line 3.
12+
Can't "goto" into a "given" block at - line 2.
1513
########
1614
# NAME goto from given topic expression
17-
no warnings 'deprecated';
1815
CORE::given(goto f){f:}
1916
EXPECT
20-
Can't "goto" into a "given" block at - line 2.
17+
Can't "goto" into a "given" block at - line 1.
2118
########
2219
# NAME goto into expression
2320
eval { goto a; 1 + do { a: } }; warn $@;

0 commit comments

Comments
 (0)