Skip Menu |

This queue is for tickets about the base CPAN distribution.

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

Owner: Nobody in particular
Requestors: gwhulbert [...]

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)

Download (untitled) / with headers
text/plain 1.1k
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 is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

Please report any issues with to