warn if not CORE::dump
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 3 Jan 2002 22:04:00 +0000 (23:04 +0100)
committerAbhijit Menon-Sen <ams@wiw.org>
Fri, 4 Jan 2002 03:27:44 +0000 (03:27 +0000)
   Message-Id: <20020103220400.A13958@rafael>

p4raw-id: //depot/perl@14053

pod/perldiag.pod
pod/perlfunc.pod
t/lib/warnings/toke
toke.c

index 68bd0c2..2c10474 100644 (file)
@@ -1289,6 +1289,11 @@ something that isn't defined yet, you don't actually have to define the
 subroutine or package before the current location.  You can use an empty
 "sub foo;" or "package FOO;" to enter a "forward" declaration.
 
+=item dump() better written as CORE::dump()
+
+(W misc) You used the obsolescent C<dump()> built-in function, without fully
+qualifying it as C<CORE::dump()>.  Maybe it's a typo.  See L<perlfunc/dump>.
+
 =item Duplicate free() ignored
 
 (S malloc) An internal routine called free() on something that had
index 93383d3..4bd69a3 100644 (file)
@@ -1204,7 +1204,9 @@ resulting confusion on the part of Perl.
 This function is now largely obsolete, partly because it's very
 hard to convert a core file into an executable, and because the
 real compiler backends for generating portable bytecode and compilable
-C code have superseded it.
+C code have superseded it.  That's why you should now invoke it as
+C<CORE::dump()>, if you don't want to be warned against a possible
+typo.
 
 If you're looking to use L<dump> to speed up your program, consider
 generating bytecode or native C code as described in L<perlcc>.  If
index 14b745d..70ff3db 100644 (file)
@@ -101,6 +101,8 @@ toke.c      AOK
         $a =  0037777777776 ;
         $a =  0037777777777 ;
         $a =  0047777777777 ;
+
+    dump() better written as CORE::dump()
      
     Mandatory Warnings
     ------------------
@@ -702,6 +704,23 @@ Integer overflow in hexadecimal number at - line 8.
 Integer overflow in octal number at - line 11.
 ########
 # toke.c
+BEGIN { $^C = 1; }
+use warnings 'misc';
+dump;
+CORE::dump;
+EXPECT
+dump() better written as CORE::dump() at - line 4.
+- syntax OK
+########
+# toke.c
+use warnings 'misc';
+use subs qw/dump/;
+sub dump { print "no warning for overriden dump\n"; }
+dump;
+EXPECT
+no warning for overriden dump
+########
+# toke.c
 use warnings 'ambiguous';
 "@mjd_previously_unused_array";        
 no warnings 'ambiguous';
diff --git a/toke.c b/toke.c
index de71cee..6f06daa 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -3813,6 +3813,10 @@ Perl_yylex(pTHX)
            }
            else {                      /* no override */
                tmp = -tmp;
+               if (tmp == KEY_dump && ckWARN(WARN_MISC)) {
+                   Perl_warner(aTHX_ WARN_MISC,
+                           "dump() better written as CORE::dump()");
+               }
                gv = Nullgv;
                gvp = 0;
                if (ckWARN(WARN_AMBIGUOUS) && hgv