Skip Menu |

This queue is for tickets about the Class-Fields CPAN distribution.

Report information
The Basics
Id: 3255
Status: resolved
Priority: 0/
Queue: Class-Fields

People
Owner: Nobody in particular
Requestors: lorensen [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 0.16



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) {
Date: Sun, 14 Sep 2003 20:41:09 -0700
From: Michael G Schwern <schwern [...] pobox.com>
To: via RT <bug-Class-Fields [...] rt.cpan.org>
CC: "AdminCc of cpan Ticket #3255": ;
Subject: Re: [cpan #3255] Bug if base class contains only private fields
RT-Send-Cc:
On Fri, Aug 15, 2003 at 12:27:07PM -0400, via RT wrote: Show quoted text
> This fork of the base/fields contains a bug! Don't install if you have a working version from your recent perl distribrution.
Just the facts, ma'am. Show quoted text
> ... 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.
Thanks. It was my "check for inheritable fields" logic that was broken. The assumption that only inheritable fields had to be paid attention to was wrong. base.pm is now seperate from Class::Fields. This will be fixed in base 2.03. -- Michael G Schwern schwern@pobox.com http://www.pobox.com/~schwern/ Do not try comedy at home! Milk & Cheese are advanced experts! Attempts at comedy can be dangerously unfunny!