This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Adapt properly More.t to run in the core
[perl5.git] / lib / fields.pm
index 44a68c5..61f02a2 100644 (file)
@@ -11,7 +11,7 @@ unless( eval q{require warnings::register; warnings::register->import; 1} ) {
 }
 use vars qw(%attr $VERSION);
 
-$VERSION = '2.12';
+$VERSION = '2.13';
 
 # constant.pm is slow
 sub PUBLIC     () { 2**0  }
@@ -124,11 +124,19 @@ if ($] < 5.009) {
     my $self = bless {}, $class;
 
     # The lock_keys() prototype won't work since we require Hash::Util :(
-    &Hash::Util::lock_keys(\%$self, keys %{$class.'::FIELDS'});
+    &Hash::Util::lock_keys(\%$self, _accessible_keys($class));
     return $self;
   }
 }
 
+sub _accessible_keys {
+    my ($class) = @_;
+    return (
+        keys %{$class.'::FIELDS'},
+        map(_accessible_keys($_), @{$class.'::ISA'}),
+    );
+}
+
 sub phash {
     die "Pseudo-hashes have been removed from Perl" if $] >= 5.009;
     my $h;