Skip Menu |
 

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 75367
Status: open
Priority: 0/
Queue: Moose

People
Owner: Nobody in particular
Requestors: abraxxa [...] cpan.org
aduitsis [...] gmail.com
Cc:
AdminCc:

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



Subject: attributes with init_arg => undef lose their value after applying a role
Download (untitled) / with headers
text/plain 278b
{ package Foo; use Moose; has _read_position => ( init_arg => undef, is => 'ro', ); } { package R; use Moose::Role; } use Test::More; my $i = Foo->new(_read_position => 23); R->meta->apply($i); is $i->_read_position, 23; done_testing;
Not a bug, attributes with init_arg => undef can't have their values set in the constructor either.
Download (untitled) / with headers
text/plain 407b
This is the correct test case that matches Catalyst::Request: { package Foo; use Moose; has _read_position => ( init_arg => undef, is => 'ro', writer => '_set_read_position', default => 0, ); } { package R; use Moose::Role; } use Test::More; my $i = Foo->new; $i->_set_read_position(23); R->meta->apply($i); is $i->_read_position, 23; done_testing;
Subject: Re: [rt.cpan.org #75367] attributes with init_arg => undef lose their value after applying a role
Date: Mon, 12 Mar 2012 11:16:23 -0500 (CDT)
To: Jesse Luehrs via RT <bug-Moose [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
Download (untitled) / with headers
text/plain 609b
On Mon, 12 Mar 2012, Jesse Luehrs via RT wrote: Show quoted text
> Queue: Moose > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=75367 > > > Not a bug, attributes with init_arg => undef can't have their values set > in the constructor either.
This sounds like a bug to me. Applying a role to an object should not change existing attributes in the object. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Subject: Re: [rt.cpan.org #75367] attributes with init_arg => undef lose their value after applying a role
Date: Mon, 12 Mar 2012 11:18:56 -0500
To: "autarch [...] urth.org via RT" <bug-Moose [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
Download (untitled) / with headers
text/plain 275b
Yes, the second test that was provided does demonstrate a bug (in the first test, the attribute never had a value, because init_arg was undef and the value was provided in the constructor). This is probably an issue with the attribute value fixups we do in rebless_instance.
Subject: applying role resets attributes with default and init_arg=>undef
Date: Fri, 10 Aug 2012 19:06:50 +0300
To: bug-moose [...] rt.cpan.org
From: Athanasios Douitsis <aduitsis [...] gmail.com>
Download (untitled) / with headers
text/plain 603b
Hi, I don't know whether this is a bug or normal behavior, but here goes: Say I have a role (ROLE1) that has an attribute with a default value (default=>'') and init_arg=>undef. I apply this role as usual with ROLE1->meta->apply( $object ), then set the attribute to a value normally. If later in my program I have to apply another role (say ROLE2) to the same object, the attribute from ROLE1 will be reset again to ''. Removing the init_arg or the default from the attribute stops this phenomenon. Is this normal? Thanks very much in advance and keep up the good work! ... -- Athanasios Douitsis


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

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