more reasonable diagnostic on keyword vs. sub ambiguity
authorGurusamy Sarathy <gsar@cpan.org>
Mon, 6 Jul 1998 20:31:44 +0000 (20:31 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Mon, 6 Jul 1998 20:31:44 +0000 (20:31 +0000)
p4raw-id: //depot/perl@1340

pod/perldiag.pod
toke.c

index c2c5be1..0805db3 100644 (file)
@@ -207,6 +207,22 @@ L<perlfunc/grep> and L<perlfunc/map> for alternatives.
 you thought.  Normally it's pretty easy to disambiguate it by supplying
 a missing quote, operator, parenthesis pair or declaration.
 
+=item Ambiguous call resolved as CORE::%s(), qualify as such or use &
+
+(W) A subroutine you have declared has the same name as a Perl keyword,
+and you have used the name without qualification for calling one or the
+other.  Perl decided to call the builtin because the subroutine is
+not imported.
+
+To force interpretation as a subroutine call, either put an ampersand
+before the subroutine name, or qualify the name with its package.
+Alternatively, you can import the subroutine (or pretend that it's
+imported with the C<use subs> pragma).
+
+To silently interpret it as the Perl operator, use the C<CORE::> prefix
+on the operator (e.g. C<CORE::log($x)>) or by declaring the subroutine
+to be an object method (see L<attrs>).
+
 =item Args must match #! line
 
 (F) The setuid emulator requires that the arguments Perl was invoked
@@ -2379,21 +2395,6 @@ may break this.
        eval "sub name { ... }";
     }
 
-=item Subroutine %s hidden by keyword; use ampersand
-
-(W) You are trying to call a subroutine that has the same name as a
-keyword.  However, because the subroutine is not imported and
-you're not using an ampersand, Perl won't call the subroutine.
-
-To force a subroutine call, either put an ampersand before the
-subroutine name, or qualify the name with its package.  Alternatively,
-you can import the subroutine (or pretend that it's imported with the
-C<use subs> pragma).
-
-If the Perl operator is what you want, then eliminate this warning by
-using the CORE:: prefix on the operator (e.g. CORE::log($x)) or by
-declaring the subroutine to be an object method (see L<attrs>).
-
 =item Substitution loop
 
 (P) The substitution was looping infinitely.  (Obviously, a
diff --git a/toke.c b/toke.c
index 22fc267..ad8dfbe 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -2855,8 +2855,8 @@ yylex(void)
                gv = Nullgv;
                gvp = 0;
                if (dowarn && hgv)
-                   warn("Subroutine %s::%s hidden by keyword; use ampersand",
-                        HvNAME(GvESTASH(hgv)), GvENAME(hgv));
+                   warn("Ambiguous call resolved as CORE::%s(), "
+                        "qualify as such or use &", GvENAME(hgv));
            }
        }