Skip Menu |
Report information
Id: 133583
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: jkeenan [at] pobox.com
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: low
Type: unknown
Perl Version: (no value)
Fixed In: (no value)



Subject: Fatalize $* and $#
Date: Fri, 12 Oct 2018 11:53:25 -0400
From: James E Keenan <jkeenan [...] pobox.com>
To: perlbug [...] perl.org
Download (untitled) / with headers
text/plain 838b
In this commit we implemented a warning, present in perl-5.28, that the use of $* and $# -- both long deprecated -- was no longer supported. ##### commit a678626e6d2dd11740073117f5269f7efee639de Author: Abigail <abigail@abigail.be> AuthorDate: Sun Jan 15 13:23:34 2017 +0100 Revert "Remove deprecation warnings related to $* and $#." This reverts commit e9b5346b919b4f4cc0096af4644cb0d48d64e14c. We've decided that instead of leaving $* and $# as usuable, magic-free variables, we instead make it fatal to use them. Therefore, we restore the warnings their use gives, and in a subsequent commit, we fix the warning to indicate the version where their use becomes fatal. ##### In preparation for perl-5.30, we need to fatalize their use and adjusts tests and documentation accordingly. Thank you very much.
Download perl_V.txt
text/plain 3.1k

Message body is not shown because sender requested not to inline it.

RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 2.3k
On Fri, 12 Oct 2018 15:53:39 GMT, jkeenan@pobox.com wrote: Show quoted text
> In this commit we implemented a warning, present in perl-5.28, that the > use of $* and $# -- both long deprecated -- was no longer supported. > > ##### > commit a678626e6d2dd11740073117f5269f7efee639de > Author: Abigail <abigail@abigail.be> > AuthorDate: Sun Jan 15 13:23:34 2017 +0100 > > Revert "Remove deprecation warnings related to $* and $#." > > This reverts commit e9b5346b919b4f4cc0096af4644cb0d48d64e14c. > > We've decided that instead of leaving $* and $# as usuable, > magic-free variables, we instead make it fatal to use them. Therefore, > we restore the warnings their use gives, and in a subsequent commit, we > fix the warning to indicate the version where their use becomes fatal. > > ##### > > In preparation for perl-5.30, we need to fatalize their use and adjusts > tests and documentation accordingly. > > Thank you very much. >
A draft of an implementation of the fatalization of $* and $# can be found in the smoke-me/jkeenan/133583-fatalize-dollar-asterisk-pound branch or in the attached diff (which squashes all the patches in that branch). Smoke test results can be found at http://perl.develop-help.com/?b=smoke-me%2Fjkeenan%2F133583-fatalize-dollar-asterisk-pound. Please review the patch, particularly with respect to the following: 1. gv.c: Correct usage of Perl_croak; suitability of error message. 2. Tests: a. I took the warnings tests relevant to this issue and found in t/lib/warnings/gv and created a new file, t/lib/croak/gv Was this appropriate? b. There were individual tests in several files which used $# or $*, not necessarily for any specific reason. In order to get 'make test' to PASS, I had to remove many of these tests. This runs the risk of unintentionally reducing our test coverage. The test files in question are: lib/B/Deparse.t t/op/heredoc.t t/op/lex.t t/op/postfixderef.t t/uni/variables.t 3. Documentation: So far the only documentation file altered is pod/perldiag.pod. So I have not yet made any edits in, say, pod/perldelta.pod. Please review carefully. If satisfactory, I would like to merge to blead by Thursday, October 17, so that we can get it into the monthly release scheduled for October 20 and then see how much CPAN breakage occurs. Thank you very much. -- James E Keenan (jkeenan@cpan.org)
Subject: blead.133583.diff
Download blead.133583.diff
text/x-patch 12.1k
diff --git a/MANIFEST b/MANIFEST index bcfd99c65b..3180dcf3f3 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5422,6 +5422,7 @@ t/lib/common.pl Helper for lib/{warnings,feature}.t t/lib/commonsense.t See if configuration meets basic needs t/lib/Count.pm Helper for t/op/method.t t/lib/croak.t Test calls to Perl_croak() in the C source. +t/lib/croak/gv Test croak calls from gv.c t/lib/croak/mg Test croak calls from mg.c t/lib/croak/op Test croak calls from op.c t/lib/croak/pp Test croak calls from pp.c diff --git a/gv.c b/gv.c index 4f3a272d1f..798c3ae92f 100644 --- a/gv.c +++ b/gv.c @@ -2203,12 +2203,10 @@ S_gv_magicalize(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, break; case '*': /* $* */ case '#': /* $# */ - if (sv_type == SVt_PV) - /* diag_listed_as: $* is no longer supported. Its use will be fatal in Perl 5.30 */ - Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), - "$%c is no longer supported. Its use " - "will be fatal in Perl 5.30", *name); - break; + if (sv_type == SVt_PV) + /* diag_listed_as: $* is no longer supported as of Perl 5.30 */ + Perl_croak(aTHX_ "$%c is no longer supported as of Perl 5.30", *name); + break; case '\010': /* $^H */ { HV *const hv = GvHVn(gv); @@ -2311,11 +2309,8 @@ S_maybe_multimagic_gv(pTHX_ GV *gv, const char *name, const svtype sv_type) require_tie_mod_s(gv, *name, "Tie::Hash::NamedCapture", 0); } else if (sv_type == SVt_PV) { if (*name == '*' || *name == '#') { - /* diag_listed_as: $# is no longer supported. Its use will be fatal in Perl 5.30 */ - Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, - WARN_SYNTAX), - "$%c is no longer supported. Its use " - "will be fatal in Perl 5.30", *name); + /* diag_listed_as: $* is no longer supported as of Perl 5.30 */ + Perl_croak(aTHX_ "$%c is no longer supported as of Perl 5.30", *name); } } if (sv_type==SVt_PV || sv_type==SVt_PVGV) { diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t index 2451ce5e77..d5f830fcd7 100644 --- a/lib/B/Deparse.t +++ b/lib/B/Deparse.t @@ -1718,11 +1718,6 @@ my @x; @x = ($#{<}, $#{.}, $#{>}, $#{/}, $#{?}, $#{=}, $#+, $#{\}, $#{|}, $#-); @x = ($#{;}, $#{:}, $#{1}), $#_; #### -# ${#} interpolated -# It's a known TODO that warnings are deparsed as bits, not textually. -no warnings; -() = "${#}a"; -#### # [perl #86060] $( $| $) in regexps need braces /${(}/; /${|}/; diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 4a50e5d9d8..afac8798f8 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -3231,10 +3231,10 @@ code. You specified a character that has the given plainer way of writing it, and which is also portable to platforms running with different character sets. -=item $* is no longer supported. Its use will be fatal in Perl 5.30 +=item $* is no longer supported as of Perl 5.30 -(D deprecated, syntax) The special variable C<$*>, deprecated in older -perls, has been removed as of 5.10.0 and is no longer supported. In +(F) The special variable C<$*>, deprecated in older perls, was removed in +5.10.0, is no longer supported and is a fatal error as of Perl 5.30. In previous versions of perl the use of C<$*> enabled or disabled multi-line matching within a string. @@ -3245,14 +3245,12 @@ then all regular expressions behaved as if they were written using C</m>.) Use of this variable will be a fatal error in Perl 5.30. -=item $# is no longer supported. Its use will be fatal in Perl 5.30 +=item $# is no longer supported as of Perl 5.30 -(D deprecated, syntax) The special variable C<$#>, deprecated in older -perls, has been removed as of 5.10.0 and is no longer supported. You +(F) The special variable C<$#>, deprecated in older perls, was removed as of +5.10.0, is no longer supported and is a fatal error as of Perl 5.30. You should use the printf/sprintf functions instead. -Use of this variable will be a fatal error in Perl 5.30. - =item '%s' is not a code reference (W overload) The second (fourth, sixth, ...) argument of diff --git a/t/lib/croak/gv b/t/lib/croak/gv new file mode 100644 index 0000000000..dabc099570 --- /dev/null +++ b/t/lib/croak/gv @@ -0,0 +1,71 @@ +__END__ +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$a = ${"#"}; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$a = ${"*"}; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$a = ${#}; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$a = ${*}; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$a = $#; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$a = $*; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$# = $a; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$* = $a; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$a = \$#; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$a = \$*; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$a = \$#; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$a = $*; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $# is no longer supported as of Perl 5.30 [RT #133583] +$a = $#; +EXPECT +$# is no longer supported as of Perl 5.30 at - line 1. +######## +# NAME $* is no longer supported as of Perl 5.30 [RT #133583] +$a = $*; +EXPECT +$* is no longer supported as of Perl 5.30 at - line 1. diff --git a/t/lib/warnings/2use b/t/lib/warnings/2use index a02505eff1..4df98e2baa 100644 --- a/t/lib/warnings/2use +++ b/t/lib/warnings/2use @@ -359,21 +359,3 @@ EXPECT Reversed += operator at - line 6. Use of uninitialized value $c in scalar chop at - line 9. ######## - -# Check that deprecation warnings are not implicitly disabled by use -$*; -use warnings "void"; -$#; -EXPECT -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. -Useless use of a variable in void context at - line 5. -######## - -# Check that deprecation warnings are not implicitly disabled by no -$*; -no warnings "void"; -$#; -EXPECT -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. diff --git a/t/lib/warnings/gv b/t/lib/warnings/gv index 122e4904e4..2a2dcf4547 100644 --- a/t/lib/warnings/gv +++ b/t/lib/warnings/gv @@ -3,12 +3,6 @@ Can't locate package %s for @%s::ISA @ISA = qw(Fred); joe() - $# is no longer supported - $* is no longer supported - - $a = ${"#"} ; - $a = ${"*"} ; - Name "main::a" used only once: possible typo Mandatory Warnings ALL TODO @@ -32,66 +26,6 @@ EXPECT Undefined subroutine &main::joe called at - line 3. ######## # gv.c -$a = ${"#"}; -$a = ${"*"}; -no warnings 'deprecated' ; -$a = ${"#"}; -$a = ${"*"}; -EXPECT -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. -######## -# gv.c -$a = ${#}; -$a = ${*}; -no warnings 'deprecated' ; -$a = ${#}; -$a = ${*}; -EXPECT -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. -######## -# gv.c -$a = $#; -$a = $*; -$# = $a; -$* = $a; -$a = \$#; -$a = \$*; -no warnings 'deprecated' ; -$a = $#; -$a = $*; -$# = $a; -$* = $a; -$a = \$#; -$a = \$*; -EXPECT -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 4. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 6. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 7. -######## -# gv.c -@a = @#; -@a = @*; -$a = $#; -$a = $*; -EXPECT -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 4. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 5. -######## -# gv.c -$a = $#; -$a = $*; -@a = @#; -@a = @*; -EXPECT -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 2. -$* is no longer supported. Its use will be fatal in Perl 5.30 at - line 3. -######## -# gv.c $a = ${^ENCODING}; $a = ${^E_NCODING}; ${^E_NCODING} = 1; # We pretend this variable never existed. diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index c770e9cb2c..45cdba528f 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -1030,6 +1030,7 @@ Operator or semicolon missing before *foo at - line 8. Ambiguous use of * resolved as operator * at - line 8. Operator or semicolon missing before *foo at - line 10. Ambiguous use of * resolved as operator * at - line 10. +$* is no longer supported as of Perl 5.30 at - line 14. ######## # toke.c $^W = 0 ; diff --git a/t/op/heredoc.t b/t/op/heredoc.t index 7b11852e05..ca044a3a83 100644 --- a/t/op/heredoc.t +++ b/t/op/heredoc.t @@ -109,7 +109,7 @@ HEREDOC # [perl #125540] this asserted or crashed fresh_perl_like( - q(map d$#<<<<""), + q(map d<<<<""), qr/Can't find string terminator "" anywhere before EOF at - line 1\./, {}, "Don't assert parsing a here-doc if we hit EOF early" diff --git a/t/op/lex.t b/t/op/lex.t index 90be519524..e78fad2c42 100644 --- a/t/op/lex.t +++ b/t/op/lex.t @@ -276,10 +276,7 @@ SKIP: fresh_perl_is( "stat\tt\$#0", <<'EOM', -$# is no longer supported. Its use will be fatal in Perl 5.30 at - line 1. -Number found where operator expected at - line 1, near "$#0" - (Missing operator before 0?) -Can't call method "t" on an undefined value at - line 1. +$# is no longer supported as of Perl 5.30 at - line 1. EOM {}, "[perl #129273] heap use after free or overflow" diff --git a/t/op/postfixderef.t b/t/op/postfixderef.t index c2983cf6dd..4125fc2fc7 100644 --- a/t/op/postfixderef.t +++ b/t/op/postfixderef.t @@ -16,7 +16,7 @@ BEGIN { use strict qw(refs subs); -plan(130); +plan(128); { no strict 'refs'; @@ -326,13 +326,6 @@ is "@foo", "1 2 3 4 5 6 7 8 9", 'lvalue ->$#*'; $_ = "foo"; @foo = 7..9; %foo = qw( foo oof ); -{ - no warnings 'deprecated'; - $* = 42; - is "$_->$*", 'foo->42', '->$* interpolation without feature'; - $# = 43; - is "$_->$#*", 'foo->43*', '->$#* interpolation without feature'; -} is "$_->@*", 'foo->@*', '->@* does not interpolate without feature'; is "$_->@[0]", 'foo->@[0]', '->@[ does not interpolate without feature'; is "$_->@{foo}", "foo->7 8 9", '->@{ does not interpolate without feature'; diff --git a/t/uni/variables.t b/t/uni/variables.t index 852ecaab0c..d8709a62b7 100644 --- a/t/uni/variables.t +++ b/t/uni/variables.t @@ -14,7 +14,7 @@ use utf8; use open qw( :utf8 :std ); no warnings qw(misc reserved); -plan (tests => 66892); +plan (tests => 66880); # ${single:colon} should not be treated as a simple variable, but as a # block with a label inside. @@ -134,6 +134,7 @@ for ( 0x0 .. 0xff ) { $tests++; } elsif ($chr =~ /[[:punct:][:digit:]]/a) { + next if ($chr eq '#' or $chr eq '*'); # RT 133583 # Unlike other variables, we dare not try setting the length-1 # variables that are ASCII punctuation and digits. This is
RT-Send-CC: perl5-porters [...] perl.org
I skimmed the patch and it looked reasonable. perlvar.pod will also need to get updated.
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 268b
On Sun, 14 Oct 2018 03:50:52 GMT, ether wrote: Show quoted text
> I skimmed the patch and it looked reasonable. > > perlvar.pod will also need to get updated.
Thanks for the review! (I'll keep the RT open until I actually merge.) Anyone else? -- James E Keenan (jkeenan@cpan.org)
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 136b
Following review by Tony Cook, merged to blead in commit dcb414ac3e404a94d6b3ba0a9a06e72ae0ab368d, -- James E Keenan (jkeenan@cpan.org)
Download (untitled) / with headers
text/plain 313b
Thank you for filing this report. You have helped make Perl better. With the release today of Perl 5.30.0, this and 160 other issues have been resolved. Perl 5.30.0 may be downloaded via: https://metacpan.org/release/XSAWYERX/perl-5.30.0 If you find that the problem persists, feel free to reopen this ticket.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org