Subject: | Bug if base class contains only private fields |
This fork of the base/fields contains a bug! Don't install if you have a working version from your recent perl distribrution.
fields::_dump() on a perl 5.6.1 output this:
Foo
1: _priv_foo (private)
Foo::Bar (Foo)
1: pub_foo_bar (public)
... with the following simple test program. Notice that both fields has
index "1" - Not 1 and 2 as expected. Changing the field to a public field
or adding a public field to the Foo class solves this - but as long as the
base class has no public fields, the sub-class has fields numbered from 1.
Attached is a patch which solves this, but whether it breaks something, or
could be done in a smarter way, I don't know.
package Foo;
use fields ('_priv_foo');
package Foo::Bar;
use base 'Foo';
use fields ('pub_foo_bar');
package main;
use fields;
fields::_dump;
--- base.pm-orig Wed Jun 18 21:45:34 2003
+++ base.pm Wed Jun 18 21:51:40 2003
@@ -74,7 +74,8 @@
# Check to see if there are fields to be inherited.
if ( Class::Fields::show_fields($base, 'Public') or
- Class::Fields::show_fields($base, 'Protected') ) {
+ Class::Fields::show_fields($base, 'Protected') or
+ Class::Fields::show_fields($base, 'Private') ) {
# No multiple fields inheritence *suck*
if ($fields_base) {