Subject: | UNIVERSAL::VERSION and argument checking |
As far as I can tell, the UNIVERSAL::VERSION in the perl core has always been callable with no arguments, but reads past the end of the stack (seeing the argument to pp_entersub; usually the *UNIVERSAL::VERSION glob, but possibly a string used to call the sub).
$ perl -le '*Foo = *UNIVERSAL::VERSION; $Foo::VERSION = 10; $_ = "Foo"; print $_->()'
10
$ perl -le '*Foo = *UNIVERSAL::VERSION; $Foo::VERSION = 10; $_ = \&Foo; print $_->()'
Cannot find version of an unblessed reference at -e line 1.
But version.pm’s UNIVERSAL::VERSION requires at least one argument:
$ perl -Mblib -Mversion -le '*Foo = *UNIVERSAL::VERSION; $Foo::VERSION = 10; $_ = "Foo"; print $_->()'
Usage: version::vxs::_VERSION(sv, ...) at -e line 1.
I think the former behaviour is wrong, but the latter is less helpful than it could be.
I would suggest:
Usage: UNIVERSAL::VERSION(sv, ...) at -e line 1.
I’m going to forward this to p5p, too.