Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Mouse CPAN distribution.

Report information
The Basics
Id: 74135
Status: new
Priority: 0/
Queue: Mouse

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

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



Subject: Type ScalarRef[...] not known
Hi, writing has foo => (is => 'rw', isa => "ScalarRef[Str]"); dies with the following error: scalarref.t .. The ScalarRef[Str] constraint cannot be used, because Str doesn't subtype from a parameterizable type at [...]/Mouse/Meta/TypeConstraint.pm line 40 Regards, Danijel
Subject: scalarref.t
{ package Foo; use Any::Moose; has ref => (is => 'rw', isa => 'ScalarRef'); has foo => (is => 'rw', isa => 'ScalarRef[Str]'); has bar => (is => 'rw', isa => 'ScalarRef[Bool]'); } package main; use Test::More; use strict; my $undef = undef; my $undef_ref = \$undef; my $str = 'Str'; my $str_ref = \$str; my $bool_ref = \0; eval { Foo->new(ref=>$str); fail("not ScalarRef") }; if($@) { pass("not ScalarRef") } eval { Foo->new(ref=>$str_ref); pass("ScalarRef") }; if($@) { fail("ScalarRef") } eval { Foo->new(foo=>$undef); fail("not ScalarRef[Str] 1") }; if($@) { pass("not ScalarRef[Str] 1") } eval { Foo->new(foo=>$undef_ref); fail("not ScalarRef[Str] 2") }; if($@) { pass("not ScalarRef[Str] 2") } eval { Foo->new(foo=>$str); fail("not ScalarRef[Str] 2") }; if($@) { pass("not ScalarRef[Str] 3") } eval { Foo->new(foo=>$str_ref); pass("ScalarRef[Str]") }; if($@) { fail("ScalarRef[Str]") } eval { Foo->new(bar=>$bool_ref); pass("ScalarRef[Bool]") }; if($@) { fail("ScalarRef[Bool]") } eval { Foo->new(bar=>$str_ref); fail("not ScalarRef[Bool] 1") }; if($@) { pass("not ScalarRef[Bool] 1") } eval { Foo->new(bar=>$undef); fail("not ScalarRef[Bool] 2") }; if($@) { pass("not ScalarRef[Bool] 2") } done_testing;