develooper Front page | perl.perl5.porters | Postings from September 2013

Fwd: [rt.cpan.org #88572] UNIVERSAL::VERSION and argument checking

From:
bug-version
Date:
September 10, 2013 08:26
Subject:
Fwd: [rt.cpan.org #88572] UNIVERSAL::VERSION and argument checking
Message ID:
20130910082612.6D424A46@rtcpan.develooper.com
Subject: UNIVERSAL::VERSION and argument checking
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.16-19443-1378801557-1068.0-0-0@rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 925

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.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About