In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/5c14d9877d3a861124eab75846a98fe56e74f27d?hp=14731ad1b39d44be8354a1cdd95deb70f2203fa7>
- Log ----------------------------------------------------------------- commit 5c14d9877d3a861124eab75846a98fe56e74f27d Merge: 14731ad 982110e Author: Nicholas Clark <[email protected]> Date: Thu Mar 21 09:24:08 2013 +0100 Merge in the changes that deprecate the use of @*, &*, ** and %*. Use of $* already generated a deprecation warning. This resolves RT #116943. commit 982110e06e40aad7a538cb788327cca8aaabce22 Author: Nicholas Clark <[email protected]> Date: Wed Mar 20 16:47:16 2013 +0100 Add a deprecation warning for all uses of @*, %*, &* and **. All compile-time uses of the ** typeglob now warn. M dist/B-Deparse/t/deparse.t M gv.c M pod/perldelta.pod M pod/perldiag.pod M t/lib/warnings/gv commit 53213d38f22e9356f489162e494d2ffa46ec2ca2 Author: Nicholas Clark <[email protected]> Date: Wed Mar 20 09:23:49 2013 +0100 Change the warning for $* to add ", and will become a syntax error". The intent is that $*, @*, %*, &* and ** stop being parsed as punctuation variables, freeing up the syntax for other use (possibly "splats"). M gv.c M pod/perldelta.pod M pod/perldiag.pod M t/lib/warnings/2use M t/lib/warnings/gv commit ff68367153668fa69490c3a2ec009c228a10795f Author: Nicholas Clark <[email protected]> Date: Wed Mar 20 12:00:11 2013 +0100 Generate the deprecation warnings for all uses $* or $#. Previously it would fail to be generated if another variable using the same typeglob was seen first (e.g. @* before $*), and would not be generated for the second and subsequent uses. It's hard to fix the failure to generate warnings at all without also generating them every time, and warning every time is consistent with the warnings that $[ used to generate. M dist/B-Deparse/t/deparse.t M gv.c M pod/perldelta.pod M t/lib/warnings/gv commit 340067e5ad5b9d5f9885e3c9fbc048c7e388e288 Author: Nicholas Clark <[email protected]> Date: Wed Mar 20 11:40:42 2013 +0100 Additional tests for the deprecation warnings when using $* or $#. M t/lib/warnings/gv commit 05c5ed4862ef5177d075d0723b2a0e1e4c89efbe Author: Nicholas Clark <[email protected]> Date: Wed Mar 20 14:26:56 2013 +0100 Change tie_fetch_count.t to use *] instead of **. The test is not sensitive to which typeglob is used. M t/op/tie_fetch_count.t commit 08412a26636d262ee540d5a1a457daa7113cc608 Author: Nicholas Clark <[email protected]> Date: Wed Mar 20 13:54:22 2013 +0100 Change B::Deparse's test to test interpolation of @] instead of @*. The test wasn't specifically relying on @*, so any unused punctuation variable is equally good. $] isn't going away any time soon, hence @] is unlikely to change. M dist/B-Deparse/t/deparse.t ----------------------------------------------------------------------- Summary of changes: dist/B-Deparse/t/deparse.t | 20 ++++++++---- gv.c | 38 ++++++++++++++++++++++-- pod/perldelta.pod | 19 +++++++++-- pod/perldiag.pod | 21 ++++++++++--- t/lib/warnings/2use | 4 +- t/lib/warnings/gv | 70 +++++++++++++++++++++++++++++++++++++++++++- t/op/tie_fetch_count.t | 2 +- 7 files changed, 151 insertions(+), 23 deletions(-) diff --git a/dist/B-Deparse/t/deparse.t b/dist/B-Deparse/t/deparse.t index dce0460..f26aa96 100644 --- a/dist/B-Deparse/t/deparse.t +++ b/dist/B-Deparse/t/deparse.t @@ -211,11 +211,11 @@ like($a, qr/-e syntax OK/, "Deparse does not hang when traversing stash circularities"); # [perl #93990] -@* = (); -is($deparse->coderef2text(sub{ print "@{*}" }), +@] = (); +is($deparse->coderef2text(sub{ print "@{]}" }), q<{ - print "@{*}"; -}>, 'curly around to interpolate "@{*}"'); + print "@{]}"; +}>, 'curly around to interpolate "@{]}"'); is($deparse->coderef2text(sub{ print "@{-}" }), q<{ print "@-"; @@ -1053,13 +1053,19 @@ print $_; #### # $#- $#+ $#{%} etc. my @x; -@x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}, $#{*}); +@x = ($#{`}, $#{~}, $#{!}, $#{@}, $#{$}, $#{%}, $#{^}, $#{&}); @x = ($#{(}, $#{)}, $#{[}, $#{{}, $#{]}, $#{}}, $#{'}, $#{"}, $#{,}); @x = ($#{<}, $#{.}, $#{>}, $#{/}, $#{?}, $#{=}, $#+, $#{\}, $#{|}, $#-); @x = ($#{;}, $#{:}); #### -# ${#} interpolated (the first line magically disables the warning) -() = *#; +# $#{*} +# It's a known TODO that warnings are deparsed as bits, not textually. +no warnings; +() = $#{*}; +#### +# ${#} 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/gv.c b/gv.c index 8ac08ab..d96bde8 100644 --- a/gv.c +++ b/gv.c @@ -1628,13 +1628,34 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, if (add) { GvMULTI_on(gv); gv_init_svtype(gv, sv_type); + /* You reach this path once the typeglob has already been created, + either by the same or a different sigil. If this path didn't + exist, then (say) referencing $! first, and %! second would + mean that %! was not handled correctly. */ if (len == 1 && stash == PL_defstash) { if (sv_type == SVt_PVHV || sv_type == SVt_PVGV) { if (*name == '!') require_tie_mod(gv, "!", newSVpvs("Errno"), "TIEHASH", 1); else if (*name == '-' || *name == '+') require_tie_mod(gv, name, newSVpvs("Tie::Hash::NamedCapture"), "TIEHASH", 0); - } + } else if (sv_type == SVt_PV && *name == '#') { + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, + WARN_SYNTAX), + "$# is no longer supported"); + } + if (*name == '*') { + if (sv_type == SVt_PV) + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, + WARN_SYNTAX), + "$* is no longer supported, and will become a syntax error"); + else + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), + "%c* is deprecated, and will become a syntax error", + sv_type == SVt_PVAV ? '@' + : sv_type == SVt_PVCV ? '&' + : sv_type == SVt_PVHV ? '%' + : '*'); + } if (sv_type==SVt_PV || sv_type==SVt_PVGV) { switch (*name) { case '[': @@ -1923,11 +1944,22 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, break; } case '*': /* $* */ + if (sv_type == SVt_PV) + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), + "$* is no longer supported, and will become a syntax error"); + else { + Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), + "%c* is deprecated, and will become a syntax error", + sv_type == SVt_PVAV ? '@' + : sv_type == SVt_PVCV ? '&' + : sv_type == SVt_PVHV ? '%' + : '*'); + } + break; case '#': /* $# */ if (sv_type == SVt_PV) - /* diag_listed_as: $* is no longer supported */ Perl_ck_warner_d(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX), - "$%c is no longer supported", *name); + "$# is no longer supported"); break; case '\010': /* $^H */ { diff --git a/pod/perldelta.pod b/pod/perldelta.pod index 2c964dd..68f070f 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -192,19 +192,30 @@ XXX L<message|perldiag/"message"> =item * -XXX L<message|perldiag/"message"> +L%c* is deprecated, and will become a syntax error|perldiag/"%c* is deprecated, and will become a syntax error"> + +Use of C<@*>, C<&*>, C<**> or C<%*> is now deprecated, and will generate a +compile time warning, enabled by default. In future such code will fail to +compile with a syntax error. Removing these variables, along with C<$*>, +will permit future syntax additions. =back =head2 Changes to Existing Diagnostics -XXX Changes (i.e. rewording) of diagnostic messages go here - =over 4 =item * -XXX Describe change here +L<$* is no longer supported, and will become a syntax error|perldiag/"$* is no longer supported, and will become a syntax error"> + +The warning that use of C<$*> and C<$#> is no longer supported is now +generated for every location that references them. Previously it would fail +to be generated if another variable using the same typeglob was seen first +(e.g. C<@*> before C<$*>), and would not be generated for the second and +subsequent uses. (It's hard to fix the failure to generate warnings at all +without also generating them every time, and warning every time is +consistent with the warnings that C<$[> used to generate.) =back diff --git a/pod/perldiag.pod b/pod/perldiag.pod index d9ebe57..17d13ce 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -2602,18 +2602,29 @@ with 'useperlio'. (F) Your machine doesn't implement the sockatmark() functionality, neither as a system call nor an ioctl call (SIOCATMARK). -=item $* is no longer supported +=item $* is no longer supported, and will become a syntax error -(D deprecated, syntax) The special variable C<$*>, deprecated in older -perls, has been removed as of 5.9.0 and is no longer supported. In -previous versions of perl the use of C<$*> enabled or disabled multi-line -matching within a string. +(D deprecated, syntax) The special variable C<$*>, which has had no +effect since v5.10.0, will be removed soon. Currently code which mentions +this variable compiles with this warning, but the variable is no longer +magical, hence reads and writes have no side effects. In future such code +will fail to compile with a syntax error. + +Prior to v5.10.0 the use of C<$*> enabled or disabled multi-line matching +within a string. Instead of using C<$*> you should use the C</m> (and maybe C</s>) regexp modifiers. You can enable C</m> for a lexical scope (even a whole file) with C<use re '/m'>. (In older versions: when C<$*> was set to a true value then all regular expressions behaved as if they were written using C</m>.) +=item %c* is deprecated, and will become a syntax error + +(D deprecated, syntax) The punctuation variables C<@*>, C<&*>, C<**> and +C<%*> will be removed soon. In future such code will fail to compile with a +syntax error. Removing these variables along with C<$*> will permit future +syntax additions. + =item $# is no longer supported (D deprecated, syntax) The special variable C<$#>, deprecated in older diff --git a/t/lib/warnings/2use b/t/lib/warnings/2use index c0d203a..6c7f56f 100644 --- a/t/lib/warnings/2use +++ b/t/lib/warnings/2use @@ -365,7 +365,7 @@ $*; use warnings "void"; $#; EXPECT -$* is no longer supported at - line 3. +$* is no longer supported, and will become a syntax error at - line 3. $# is no longer supported at - line 5. Useless use of a variable in void context at - line 5. ######## @@ -375,5 +375,5 @@ $*; no warnings "void"; $#; EXPECT -$* is no longer supported at - line 3. +$* is no longer supported, and will become a syntax error at - line 3. $# is no longer supported at - line 5. diff --git a/t/lib/warnings/gv b/t/lib/warnings/gv index 6101f69..332810c 100644 --- a/t/lib/warnings/gv +++ b/t/lib/warnings/gv @@ -60,7 +60,75 @@ $a = ${"#"}; $a = ${"*"}; EXPECT $# is no longer supported at - line 2. -$* is no longer supported at - line 3. +$* is no longer supported, and will become a syntax error at - line 3. +######## +# gv.c +$a = ${#}; +$a = ${*}; +no warnings 'deprecated' ; +$a = ${#}; +$a = ${*}; +EXPECT +$# is no longer supported at - line 2. +$* is no longer supported, and will become a syntax error 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 at - line 2. +$* is no longer supported, and will become a syntax error at - line 3. +$# is no longer supported at - line 4. +$* is no longer supported, and will become a syntax error at - line 5. +$# is no longer supported at - line 6. +$* is no longer supported, and will become a syntax error at - line 7. +######## +# gv.c +@a = @#; +@a = @*; +$a = $#; +$a = $*; +EXPECT +@* is deprecated, and will become a syntax error at - line 3. +$# is no longer supported at - line 4. +$* is no longer supported, and will become a syntax error at - line 5. +######## +# gv.c +$a = $#; +$a = $*; +@a = @#; +@a = @*; +EXPECT +$# is no longer supported at - line 2. +$* is no longer supported, and will become a syntax error at - line 3. +@* is deprecated, and will become a syntax error at - line 5. +######## +# gv.c +$a = \@*; +$a = \&*; +$a = \**; +$a = \%*; +no warnings 'deprecated' ; +$a = \@*; +$a = \&*; +$a = \**; +$a = \%*; +EXPECT +@* is deprecated, and will become a syntax error at - line 2. +&* is deprecated, and will become a syntax error at - line 3. +** is deprecated, and will become a syntax error at - line 4. +%* is deprecated, and will become a syntax error at - line 5. ######## # gv.c use warnings 'syntax' ; diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index 240d23a..6b2eb79 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -172,7 +172,7 @@ $dummy = %$var3 ; check_count '%{}'; $dummy = keys $var3 ; check_count 'keys hashref'; { no strict 'refs'; - tie my $var4 => 'main', **; + tie my $var4 => 'main', *]; $dummy = *$var4 ; check_count '*{}'; } -- Perl5 Master Repository
