[perl #43242] "use base" breaks code containing peculiarly named constant
authorMartin Becker <unknown>
Mon, 18 Jun 2007 09:48:54 +0000 (02:48 -0700)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 19 Jun 2007 12:13:20 +0000 (12:13 +0000)
From: Martin Becker (via RT) <perlbug-followup@perl.org>
Message-ID: <rt-3.6.HEAD-7948-1182185333-640.43242-75-0@perl.org>

plus a test case

p4raw-id: //depot/perl@31420

lib/base.pm
lib/base/t/base.t

index 8bcbb5f..f1644a8 100644 (file)
@@ -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 {
index d0e94f8..7a707de 100644 (file)
@@ -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' );