Skip Menu |

This queue is for tickets about the Dios CPAN distribution.

Report information
The Basics
Id: 122501
Status: resolved
Priority: 0/
Queue: Dios

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

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



Subject: Declaring hash attribute causes error when calling method
Declaring an instance attribute as a hash, e.g. class Foo { has %bar is rw; method baz (--> Str) { return "bat" } } Causes an error the first time a method other than 'new' is called: my $foo = Foo->new; $foo->baz; # Assigned value is not a reference at... (line no where the method being called was defined) Nor is there any output that would help to identify the source of the issue. Adding an initializer to a reference value silences the error: has %bar is rw = {}; -- -Jeff Ober
I should also note that an array attribute does not have the same issue. This works fine: has @bar is rw; On Sat Jul 15 23:15:06 2017, JEFFOBER wrote: Show quoted text
> Declaring an instance attribute as a hash, e.g. > > class Foo { > has %bar is rw; > method baz (--> Str) { return "bat" } > } > > Causes an error the first time a method other than 'new' is called: > > my $foo = Foo->new; $foo->baz; > # Assigned value is not a reference at... (line no where the method > being called was defined) > > Nor is there any output that would help to identify the source of the > issue. Adding an initializer to a reference value silences the error: > > has %bar is rw = {};
-- -Jeff Ober
Subject: Re: [rt.cpan.org #122501] Declaring hash attribute causes error when calling method
Date: Sun, 16 Jul 2017 15:19:16 +1000
To: bug-Dios [...] rt.cpan.org
From: Damian Conway <damian [...] conway.org>
Thanks, Jeff. The bug was caused by changes in Perl's parser between 5.18 and 5.22. I've coded around that change (the hint about arrays being unaffected was especially helpful in tracking the problem down and finding a workaround). I've just uploaded a new release to CPAN, which should neutralize the issue. Please let me know if it doesn't. Very much appreciated! Damian