Re: why does default not trigger coerce?

[email protected] (Stevan Little)
Newsgroups perl.moose
Message-ID <[email protected]>
Benh,

On Aug 24, 2008, at 6:59 PM, benh wrote:
> ok this is an overly simplistic example of what I'm trying to do but
> in the end I was expecting that default would trigger coerce, though
> it looks like it does not. Should it? or am I expecting something to
> work in a completely stupid way (it's happened before)?

No, according to the code coerce will always fire for a default, I  
think the problem is ...

>
> has data => (
>    is      => 'rw',
>    isa     => 'split_types',
>    coerce  => 1,
>    default => sub{ () },
> );

'default' is returning nothing here, it should be returning []

> # THIS TEST FAILS!
> lives_ok { My::Test->new }, q{~shouldn't~ this pass?};

I suspect that if you printed out the exception, it would tell you  
that the value returned from default did not pass the type constraint.

- Stevan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.