mirror of
https://github.com/Perl/perl5.git
synced 2026-01-26 08:38:23 +00:00
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.
This commit is contained in:
parent
9bb0c18be2
commit
f7c24445e8
11
pp_ctl.c
11
pp_ctl.c
@ -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;
|
||||
@ -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 */
|
||||
@ -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;
|
||||
|
||||
@ -1,23 +1,20 @@
|
||||
__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
|
||||
eval { goto a; 1 + do { a: } }; warn $@;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user