From a23e475982a09b6a45b0f3d80d5037423970e6c0 Mon Sep 17 00:00:00 2001 From: James E Keenan Date: Fri, 27 Oct 2023 21:22:36 -0400 Subject: [PATCH] Announce 5.42 removal of goto to jump into construct perlfunc: clarify documentation per suggestion from Hugo van der Sanden in https://github.com/Perl/perl5/pull/21601. Fixes #16275 --- pod/perldiag.pod | 2 +- pod/perlfunc.pod | 3 ++- pp_ctl.c | 4 +++- t/op/goto.t | 8 +++++++- t/porting/deprecation.t | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index aa605f04adc3..870e923b12a8 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -7664,7 +7664,7 @@ repeatedly, the C has no effect. =item Use of "goto" to jump into a construct is deprecated (D deprecated::goto_construct) Using C to jump from an outer scope into an inner -scope is deprecated and should be avoided. +scope is deprecated and will be removed completely in Perl 5.42. This was deprecated in Perl 5.12. diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 651dad1c53e4..3364c1fd5eb6 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3626,7 +3626,8 @@ Also, unlike most named operators, this has the same precedence as assignment. Use of C or C 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 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 loop, or a C block. In general, it may not be used to jump into the parameter diff --git a/pp_ctl.c b/pp_ctl.c index a509206a0822..d3b3f178098d 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -3552,7 +3552,9 @@ PP(pp_goto) ? 2 : 1; if (enterops[i]) - deprecate(WARN_DEPRECATED__GOTO_CONSTRUCT, "Use of \"goto\" to jump into a construct"); + deprecate_fatal_in(WARN_DEPRECATED__GOTO_CONSTRUCT, + "5.42", + "Use of \"goto\" to jump into a construct"); } /* pop unwanted frames */ diff --git a/t/op/goto.t b/t/op/goto.t index 592f55bbec30..c2a16fe7d1b1 100644 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -16,7 +16,13 @@ plan tests => 134; our $TODO; my $deprecated = 0; -local $SIG{__WARN__} = sub { if ($_[0] =~ m/jump into a construct/) { $deprecated++; } else { warn $_[0] } }; + +local $SIG{__WARN__} = sub { + if ($_[0] =~ m/jump into a construct.*?, and will become fatal in Perl 5\.42/) { + $deprecated++; + } + else { warn $_[0] } +}; our $foo; while ($?) { diff --git a/t/porting/deprecation.t b/t/porting/deprecation.t index 109818fe6f51..67f759e5c6c1 100644 --- a/t/porting/deprecation.t +++ b/t/porting/deprecation.t @@ -103,7 +103,7 @@ if (-e ".git") { goto LABEL; DONE: like($warning, - qr/Use of "goto" to jump into a construct is deprecated/, + qr/Use of "goto" to jump into a construct is deprecated, and will become fatal in Perl 5\.42/, "Got expected deprecation warning"); } # Test that we can silence deprecation warnings with "no warnings 'deprecated'"