From 5315574d134a1fb58aaf7b1730a6eef7afd7ba4c Mon Sep 17 00:00:00 2001 From: Gurusamy Sarathy Date: Mon, 6 Jul 1998 20:31:44 +0000 Subject: [PATCH] more reasonable diagnostic on keyword vs. sub ambiguity p4raw-id: //depot/perl@1340 --- pod/perldiag.pod | 31 ++++++++++++++++--------------- toke.c | 4 ++-- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index c2c5be1..0805db3 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -207,6 +207,22 @@ L and L 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 pragma). + +To silently interpret it as the Perl operator, use the C prefix +on the operator (e.g. C) or by declaring the subroutine +to be an object method (see L). + =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 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). - =item Substitution loop (P) The substitution was looping infinitely. (Obviously, a diff --git a/toke.c b/toke.c index 22fc267..ad8dfbe 100644 --- 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)); } } -- 2.7.4