Let Lint private_names catch out-of-package _foo methods.
Malcolm Beattie [Wed, 3 Sep 1997 13:41:20 +0000 (13:41 +0000)]
p4raw-id: //depot/perlext/Compiler@52

B/Lint.pm

index 4e34545..3b4ea7e 100644 (file)
--- a/B/Lint.pm
+++ b/B/Lint.pm
@@ -183,6 +183,15 @@ sub B::UNOP::lint {
        warning("Implicit scalar context for %s in %s",
                $ppaddr eq "pp_rv2av" ? "array" : "hash", $parent->desc);
     }
+    if ($check{private_names} && $ppaddr eq "pp_method") {
+       my $methop = $op->first;
+       if ($methop->ppaddr eq "pp_const") {
+           my $method = $methop->sv->PV;
+           if ($method =~ /^_/ && !defined(&{"$curstash\::$method"})) {
+               warning("Illegal reference to private method name $method");
+           }
+       }
+    }
 }
 
 sub B::PMOP::lint {