diff options
author | Nicholas Clark <nick@ccl4.org> | 2013-03-21 09:24:08 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2013-03-21 09:24:30 +0100 |
commit | 5c14d9877d3a861124eab75846a98fe56e74f27d (patch) | |
tree | e066a5b50eb3efeb3074649db1ffd561fc376bb1 | |
parent | 14731ad1b39d44be8354a1cdd95deb70f2203fa7 (diff) | |
parent | 982110e06e40aad7a538cb788327cca8aaabce22 (diff) | |
download | perl-5c14d9877d3a861124eab75846a98fe56e74f27d.tar.gz |
Merge in the changes that deprecate the use of @*, &*, ** and %*.
Use of $* already generated a deprecation warning.
This resolves RT #116943.
-rw-r--r-- | dist/B-Deparse/t/deparse.t | 20 | ||||
-rw-r--r-- | gv.c | 38 | ||||
-rw-r--r-- | pod/perldelta.pod | 19 | ||||
-rw-r--r-- | pod/perldiag.pod | 21 | ||||
-rw-r--r-- | t/lib/warnings/2use | 4 | ||||
-rw-r--r-- | t/lib/warnings/gv | 70 | ||||
-rw-r--r-- | 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 dce0460cc3..f26aa969d4 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 @@ -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 2c964dd1ef..68f070f5a1 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 d9ebe57382..17d13ceaaa 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 c0d203a399..6c7f56f3e6 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 6101f69132..332810c7e5 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 240d23aef3..6b2eb792e3 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 '*{}'; } |