Skip to content

Commit

Permalink
Jumping into constructs will be fatal in 5.28.
Browse files Browse the repository at this point in the history
  • Loading branch information
Abigail committed Nov 23, 2016
1 parent c59d30d commit 84b32f5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
26 changes: 26 additions & 0 deletions pod/perldeprecation.pod
Expand Up @@ -151,6 +151,32 @@ will be a fatal error in Perl 5.28.

You should be using two different symbols instead.



=head3 Use of "goto" to jump into a construct.

Use of C<goto> to jump from an outer scope into an inner scope was
deprecated in Perl 5.12, and it will be a fatal error in Perl 5.28.

This means, you should not write constructs like:

$x = 1;
while ($x) {
$foo = 1;
LABEL:
$bar = 1;
}
goto LABEL;

This will jump into the block belonging to C<while>. Not only has
been this a cause of subtle bugs in the past, it's generally
considered to lead to hard to understand programs.

This means, soon it's not possible anymore to write
L<Duff's device|https://www.lysator.liu.se/c/duffs-device.html> in pure Perl.
But you never wanted to do this anyway.


=head3 ${^ENCODING} is no longer supported.

The special variable C<${^ENCODING}> was used to implement
Expand Down
4 changes: 3 additions & 1 deletion pod/perldiag.pod
Expand Up @@ -6979,11 +6979,13 @@ middle of an iteration causes Perl to see a freed value.
operator. Since C<split> always tries to match the pattern
repeatedly, the C</g> has no effect.

=item Use of "goto" to jump into a construct is deprecated
=item Use of "goto" to jump into a construct is deprecated. Its use will be fatal in Perl 5.28

(D deprecated) Using C<goto> to jump from an outer scope into an inner
scope is deprecated and should be avoided.

This was deprecated in Perl 5.12, and will be a fatal error in Perl 5.28.

=item Use of inherited AUTOLOAD for non-method %s() is deprecated

(D deprecated) As an (ahem) accidental feature, C<AUTOLOAD>
Expand Down
3 changes: 2 additions & 1 deletion pod/perlfunc.pod
Expand Up @@ -3285,7 +3285,8 @@ 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. Even then, it may not be used to
deprecated and will issue a warning; it will be a fatal error in
Perl 5.28. Even then, it may not be used to
go into any construct that requires initialization, such as a
subroutine or a C<foreach> loop. It also can't be used to go into a
construct that is optimized away.
Expand Down
2 changes: 1 addition & 1 deletion pp_ctl.c
Expand Up @@ -3011,7 +3011,7 @@ PP(pp_goto)
if (*enterops && enterops[1]) {
I32 i = enterops[1]->op_type == OP_ENTER && in_block ? 2 : 1;
if (enterops[i])
deprecate("\"goto\" to jump into a construct");
deprecate_fatal_in("5.28", "Use of \"goto\" to jump into a construct is deprecated. Its use will be fatal in Perl 5.28");
}

/* pop unwanted frames */
Expand Down

0 comments on commit 84b32f5

Please sign in to comment.