From: Martin Becker Date: Mon, 18 Jun 2007 09:48:54 +0000 (-0700) Subject: [perl #43242] "use base" breaks code containing peculiarly named constant X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=28994922d860cd50218c374183da61ac17bca9a8;p=p5sagit%2Fp5-mst-13.2.git [perl #43242] "use base" breaks code containing peculiarly named constant From: Martin Becker (via RT) Message-ID: plus a test case p4raw-id: //depot/perl@31420 --- diff --git a/lib/base.pm b/lib/base.pm index 8bcbb5f..f1644a8 100644 --- a/lib/base.pm +++ b/lib/base.pm @@ -2,7 +2,7 @@ package base; use strict 'vars'; use vars qw($VERSION); -$VERSION = '2.09'; +$VERSION = '2.10'; # constant.pm is slow sub SUCCESS () { 1 } @@ -18,7 +18,7 @@ my $Fattr = \%fields::attr; sub has_fields { my($base) = shift; my $fglob = ${"$base\::"}{FIELDS}; - return( ($fglob && *$fglob{HASH}) ? 1 : 0 ); + return( ($fglob && 'GLOB' eq ref($fglob) && *$fglob{HASH}) ? 1 : 0 ); } sub has_version { diff --git a/lib/base/t/base.t b/lib/base/t/base.t index d0e94f8..7a707de 100644 --- a/lib/base/t/base.t +++ b/lib/base/t/base.t @@ -1,7 +1,7 @@ #!/usr/bin/perl -w use strict; -use Test::More tests => 11; +use Test::More tests => 12; use_ok('base'); @@ -85,3 +85,9 @@ package Test::SIGDIE; 'Base class empty error message'); } + +package Schlozhauer; +use constant FIELDS => 6; +package Basilisco; +eval q{ use base 'Schlozhauer' }; +::is( $@, '', 'Can coexist with a FIELDS constant' );