This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fatalize use of $* and $#
authorJames E Keenan <jkeenan@cpan.org>
Fri, 12 Oct 2018 15:55:40 +0000 (11:55 -0400)
committerJames E Keenan <jkeenan@cpan.org>
Wed, 17 Oct 2018 11:44:45 +0000 (07:44 -0400)
Adapt tests in various files to removal of these variables.  Add
t/lib/croak/gv to test fatalizations of $# and $* -- tests therein
adapted from tests formerly in t/lib/warnings/gv.

Per: RT # 133583

12 files changed:
MANIFEST
gv.c
lib/B/Deparse.t
pod/perldiag.pod
t/lib/croak/gv [new file with mode: 0644]
t/lib/warnings/2use
t/lib/warnings/gv
t/lib/warnings/toke
t/op/heredoc.t
t/op/lex.t
t/op/postfixderef.t
t/uni/variables.t

index bcfd99c..3180dcf 100644 (file)
--- 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 4f3a272..798c3ae 100644 (file)
--- 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) {
index 2451ce5..d5f830f 100644 (file)
@@ -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
 /${(}/;
 /${|}/;
index 4a50e5d..afac879 100644 (file)
@@ -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 (file)
index 0000000..dabc099
--- /dev/null
@@ -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.
index a02505e..4df98e2 100644 (file)
@@ -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.
index 122e490..2a2dcf4 100644 (file)
@@ -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.
index c770e9c..45cdba5 100644 (file)
@@ -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 ;
index 7b11852..ca044a3 100644 (file)
@@ -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"
index 90be519..e78fad2 100644 (file)
@@ -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"
index c2983cf..4125fc2 100644 (file)
@@ -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';
index 852ecaa..d8709a6 100644 (file)
@@ -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