This queue is for tickets about the base CPAN distribution.

Report information
The Basics
Id:
68763
Status:
new
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
gwhulbert [...] eol.ca
Cc:
AdminCc:

BugTracker
Severity:
Important
Broken in:
(no value)
Fixed in:
(no value)



The procedure documented in the 'fields' module for creating a subclass is not transitive. Otherwise, if C subclasses B subclasses A, it is necessary in C to write: $self = $self->SUPER::new(@_); or the fields do not get initialized. In B we can write: $self->SUPER::new(@_); as documented. The reason that this fails in C is that B assigns to $self without checking if it is already a reference. To make the subclassing method is transitive, it is sufficient to change this line: my $self = fields::new($class); to this: my $self = ref($class) ? $class : fields::new($class); and then the line: $self->SUPER::new(@_); works in both B and C. Here is the context from 'perldoc fields' (white-space edited to fit): # subclassing { package Bar; use base 'Foo'; use fields qw(baz _Bar_private); # not shared with Foo sub new { my $class = shift; my $self = fields::new($class); $self->SUPER::new(); # init base fields $self->{baz} = 10; # init own fields $self->{_Bar_private} = "this is Bar's secret"; return $self; } }


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.