summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2002-01-03 23:04:00 +0100
committerAbhijit Menon-Sen <ams@wiw.org>2002-01-04 03:27:44 +0000
commitac206dc8afc56c3af5eccaed5ba83dda4e594b6e (patch)
treed973c34991517a76cf31a022c4ed9556dbca333d
parentd8f6a7325d6b2ec46e8cdc1ec4b5e1ad4a86abd0 (diff)
downloadperl-ac206dc8afc56c3af5eccaed5ba83dda4e594b6e.tar.gz
warn if not CORE::dump
Message-Id: <20020103220400.A13958@rafael> p4raw-id: //depot/perl@14053
-rw-r--r--pod/perldiag.pod5
-rw-r--r--pod/perlfunc.pod4
-rw-r--r--t/lib/warnings/toke19
-rw-r--r--toke.c4
4 files changed, 31 insertions, 1 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 68bd0c2a1c..2c10474813 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -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
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 93383d3f01..4bd69a3f14 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -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
diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke
index 14b745da22..70ff3dbbf6 100644
--- a/t/lib/warnings/toke
+++ b/t/lib/warnings/toke
@@ -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 de71ceebed..6f06daa87f 100644
--- 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