-
Notifications
You must be signed in to change notification settings - Fork 589
Open
Description
Nonexistent::Module->import()
silently succeeds. Expecting an error like
Can't locate object method "import" via package "Nonexistent::Module" (perhaps you forgot to load "Nonexistent::Module"?)
The docs say import is an ordinary method and not builtin, but that doesn't seem to be entirely true. I think this is a bug (calling any method on a non-existent object or class should result in an error);
if it can not be fixed, then I suggest updating the perlfunc entry for 'import' to explain what is happening.
#!/usr/bin/perl
use strict; use warnings;
use Data::Dumper;
$Data::Dumper::Terse = 1;
print "BEFORE:", Dumper(\%Misspelled::);
print "AGAIN :", Dumper(\%Misspelled::);
Misspelled->import(); # NO error
print "AFTER :", Dumper(\%Misspelled::);
Misspelled->othermethod(); # error as expected
Output:
BEFORE:{}
AGAIN :{}
AFTER :{
'import' => *Misspelled::import
}
Can't locate object method "othermethod" via package "Misspelled" at /tmp/test.pl line 14.
Metadata
Metadata
Assignees
Labels
No labels