Skip Menu |
 

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 61102
Status: stalled
Priority: 0/
Queue: Moose

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

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



Subject: The order of definitions of type constraints shouldn't matter
Download (untitled) / with headers
text/plain 723b
Hi, The order of definitions of type constraints matters: #!perl { package Foo; use Moose; has bar => is => 'rw', isa => 'Positive_Int' ; } { package My::Types; use Mouse::Util::TypeConstraints; subtype 'Positive_Int' => ( as 'Int', where { $_ >= 0 }, ); } __END__ The first 'Positive_Int' is dealt as a class type, and the second as a custom subtype, but if the order of definitions is reversed, both 'Positive_Int' are dealt as the same custom subtype. This behaviour seems confusing, so I think it should throw the error. This ticket is based on a bug report to Mouse: https://rt.cpan.org/Ticket/Display.html?id=61076 Regards, -- Goro Fuji (gfx) GFUJI at CPAN.org
Download (untitled) / with headers
text/plain 959b
On Mon Sep 06 03:01:56 2010, GFUJI wrote: Show quoted text
> Hi, > > The order of definitions of type constraints matters: > #!perl > { > package Foo; > use Moose; > has bar => > is => 'rw', > isa => 'Positive_Int' > ; > } > > { > package My::Types; > use Mouse::Util::TypeConstraints; > > subtype 'Positive_Int' => ( > as 'Int', > where { $_ >= 0 }, > ); > } > __END__ > > The first 'Positive_Int' is dealt as a class type, and > the second as a custom subtype, but if the order of definitions is > reversed, both 'Positive_Int' are dealt as the same custom subtype. > > This behaviour seems confusing, so I think it should throw the error.
Moose has treated an unknown string as a class name for a really long time. I agree that this can be confusing, and personally I'd prefer that unknown names cause an error, but I'm not sure if we can change it. It'd certainly require a long deprecation cycle, at the very least.


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.