Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 86144
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

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



Subject: Writers behave inconsistently based on MOO_XS_DISABLE
Class::XSAccessor-generated writers behave differently from Moo's pure Perl writers. The attached test case will demonstrate the issue... 50% of the time.
Subject: moo-setters-inconsistent.t
#!/usr/bin/env perl use strict; use warnings; use Test::More; use Test::Fatal; BEGIN { $ENV{MOO_XS_DISABLE} = int(rand(2)) }; package Foo { use Moo; has foo => (is => "bare", reader => "get_foo", writer => "set_foo"); }; is(exception { Foo->new->set_foo }, undef); done_testing;
Subject: Re: [rt.cpan.org #86144] Writers behave inconsistently based on MOO_XS_DISABLE
Date: Fri, 14 Jun 2013 09:42:59 -0700
To: Toby Inkster via RT <bug-Moo [...] rt.cpan.org>
From: Karen Etheridge <ether [...] cpan.org>
On Fri, Jun 14, 2013 at 08:21:46AM -0400, Toby Inkster via RT wrote: Show quoted text
> ... 50% of the time.
That sounds like a hash randomization bug! :)
On Fri Jun 14 14:21:45 2013, TOBYINK wrote: Show quoted text
> is => "bare"
Are you sure that's supported in Moo? It's not documented in the latest release.
On 2013-06-18T15:08:26+01:00, MITHALDU wrote: Show quoted text
> On Fri Jun 14 14:21:45 2013, TOBYINK wrote:
> > is => "bare"
> > Are you sure that's supported in Moo?
Dunno. Seems to work. That's not really the point though. Class::XSAccessor-generated writers die when called with no parameter. Moose-generated writers do not; they default the parameter to undef. Moo emulates the Moose way, but will also attempt to use Class::XSAccessor if it can. So the behaviour of writers is inconsistent depending on whether Class::XSAccessor is available. I'm not suggesting that Moo really needs to change anything. But it would be nice if this were documented to make sure nobody is relying on $obj->set_foo() meaning the same as $obj->set_foo(undef).
I've added a note about the use of Class::XSAccessor, and the caveats regarding it being strict about its arguments. Fixed in 1.003000.