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
400 changes: 198 additions & 202 deletions lib/warnings.pm

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion pod/perldelta.pod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@ XXX For a release on a stable branch, this section aspires to be:

=head1 Deprecations

XXX Any deprecated features, syntax, modules etc. should be listed here.
=over 4

=item *

Using C<goto> to jump into the body of a loop or other block construct from
outside is no longer permitted. [L<GH #23618|https://github.com/Perl/perl5/issues/23618>]

=back

=head2 Module removals

Expand Down
16 changes: 9 additions & 7 deletions pod/perldeprecation.pod
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,27 @@ prevailing version to another.

Category: "deprecated::subsequent_use_version"

=head2 Perl 5.42

=head3 Goto Block Construct

C<goto LABEL;> will produce a deprecated warning when jumping into the body
of a loop or other block construct from outside. For instance
C<goto LABEL;> now produces an exception when jumping into the body of a loop
or other block construct from outside. For instance

while (should_loop($x)) {
LABEL:
do_stuff();
}
goto LABEL;

will produce a warning that this behavior is deprecated. In general you should
just avoid doing this; the people that maintain your code will be grateful for
your restraint.
now throws an exception indicating that this behavior is no longer permitted.

Category: "deprecated::goto_construct"

=head2 Perl 5.42

There were no deprecations or fatalizations in Perl 5.42. (There were
deprecations we I<planned> to do in Perl 5.42 but failed to carry out; they
have been re-scheduled.)

=head2 Perl 5.40

=head3 Downgrading a C<use VERSION> to below v5.11
Expand Down
4 changes: 4 additions & 0 deletions pod/perldiag.pod
Original file line number Diff line number Diff line change
Expand Up @@ -7923,6 +7923,10 @@ For speed and efficiency reasons, Perl internally does not do full
reference-counting of iterated items, hence deleting such an item in the
middle of an iteration causes Perl to see a freed value.

=item Use of "goto" to jump into a construct is no longer permitted

(F) More TO COME.

=item Use of /g modifier is meaningless in split

(W regexp) You used the /g modifier on the pattern for a C<split>
Expand Down
19 changes: 8 additions & 11 deletions pod/perlfunc.pod
Original file line number Diff line number Diff line change
Expand Up @@ -3726,17 +3726,14 @@ delimit its argument. C<goto("NE")."XT"> is equivalent to C<goto NEXT>.
Also, unlike most named operators, this has the same precedence as
assignment.

Use of C<goto LABEL> or C<goto EXPR> to jump into a construct is
deprecated and will issue a warning; it will become a fatal error in
Perl 5.42. While still available, it may not be used to
go into any construct that requires initialization, such as a
subroutine, a C<foreach> loop, or a C<given>
block. In general, it may not be used to jump into the parameter
of a binary or list operator, but it may be used to jump into the
I<first> parameter of a binary operator. (The C<=>
assignment operator's "first" operand is its right-hand
operand.) It also can't be used to go into a
construct that is optimized away.
Use of C<goto LABEL> or C<goto EXPR> to jump into a construct becomes an
exception in Perl 5.44; a fatal error notification is emitted. It may not be
used to go into any construct that requires initialization, such as a
subroutine, a C<foreach> loop, or a C<given> block. In general, it may not be
used to jump into the parameter of a binary or list operator, but it may be
used to jump into the I<first> parameter of a binary operator. (The C<=>
assignment operator's "first" operand is its right-hand operand.) It also
can't be used to go into a construct that is optimized away.

The C<goto &NAME> form is quite different from the other forms of
C<goto>. In fact, it isn't a goto in the normal sense at
Expand Down
5 changes: 1 addition & 4 deletions pp_ctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -3683,10 +3683,7 @@ PP(pp_goto)
}

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

croak("Use of \"goto\" to jump into a construct is no longer permitted");

if (do_dump) {
#ifdef VMS
Expand Down
3 changes: 2 additions & 1 deletion regen/warnings.pl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# This script is normally invoked from regen.pl.

$VERSION = '1.75';
$VERSION = '1.76';

BEGIN {
require './regen/regen_lib.pl';
Expand Down Expand Up @@ -189,6 +189,7 @@ BEGIN
# the experiments were successful (or abandonned),
# so no warning bit is needed anymore
my %NO_BIT_FOR = map { ( uc $_ => 1, $_ => 1 ) } qw(
deprecated::goto_construct
deprecated::smartmatch
experimental::lexical_subs
experimental::postderef
Expand Down
37 changes: 1 addition & 36 deletions t/comp/package_block.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!./perl

print "1..7\n";
print "1..5\n";

$main::result = "";
eval q{
Expand Down Expand Up @@ -55,38 +55,3 @@ eval q{
$main::result .= "f(".__LINE__.")";
};
print $main::result eq "a(2)b(4)c(6)d(8)e(10)f(12)" ? "ok 5\n" : "not ok 5\n";

$main::result = "";
$main::warning = "";
$SIG{__WARN__} = sub { $main::warning .= $_[0]; };
eval q{
$main::result .= "a(".__PACKAGE__."/".eval("__PACKAGE__").")";
goto l0;
$main::result .= "b(".__PACKAGE__."/".eval("__PACKAGE__").")";
package Foo {
$main::result .= "c(".__PACKAGE__."/".eval("__PACKAGE__").")";
l0:
$main::result .= "d(".__PACKAGE__."/".eval("__PACKAGE__").")";
goto l1;
$main::result .= "e(".__PACKAGE__."/".eval("__PACKAGE__").")";
}
$main::result .= "f(".__PACKAGE__."/".eval("__PACKAGE__").")";
l1:
$main::result .= "g(".__PACKAGE__."/".eval("__PACKAGE__").")";
goto l2;
$main::result .= "h(".__PACKAGE__."/".eval("__PACKAGE__").")";
package Bar {
l2:
$main::result .= "i(".__PACKAGE__."/".eval("__PACKAGE__").")";
}
$main::result .= "j(".__PACKAGE__."/".eval("__PACKAGE__").")";
};
print $main::result eq
"a(main/main)d(Foo/Foo)g(main/main)i(Bar/Bar)j(main/main)" ?
"ok 6\n" : "not ok 6\n";
print $main::warning =~ /\A
Use\ of\ "goto"\ [^\n]*\ line\ 3\.\n
Use\ of\ "goto"\ [^\n]*\ line\ 15\.\n
\z/x ? "ok 7\n" : "not ok 7\n";

1;
Loading
Loading