Skip Menu |
 

This queue is for tickets about the Moose CPAN distribution.

Report information
The Basics
Id: 79299
Status: rejected
Priority: 0/
Queue: Moose

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

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



Subject: Package is not visible when Moose use DateTime|Undef union
Download (untitled) / with headers
text/plain 3.2k
Hi This is weird bug and I'm not sure if it belongs here or in Moose module, however DateTime is the only module causing such problem. When DateTime is used in Moose type checking it works fine: $ perl -e 'use DateTime; package A; use Moose; has "foo" => ("is" => "ro", "isa" => "DateTime"); print "alive\n"' alive But when combining with Undef is somehow stops seeing DateTime definition: $ perl -e 'use DateTime; package A; use Moose; has "foo" => ("is" => "ro", "isa" => "DateTime|Undef"); print "alive\n"' Could not locate type constraint (DateTime) for the union at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Util/TypeConstraints.pm line 89 Moose::Util::TypeConstraints::create_type_constraint_union('DateTime|Undef') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Util/TypeConstraints.pm line 218 Moose::Util::TypeConstraints::find_or_parse_type_constraint('DateTime|Undef') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Util/TypeConstraints.pm line 204 Moose::Util::TypeConstraints::find_or_create_isa_type_constraint('DateTime|Undef') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Meta/Attribute.pm line 325 Moose::Meta::Attribute::_process_isa_option('Moose::Meta::Attribute', 'foo', 'HASH(0x7fb208b26070)') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Meta/Attribute.pm line 252 Moose::Meta::Attribute::_process_options('Moose::Meta::Attribute', 'foo', 'HASH(0x7fb208b26070)') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Meta/Attribute.pm line 57 Moose::Meta::Attribute::new('Moose::Meta::Attribute', 'foo', 'isa', 'DateTime|Undef', 'definition_context', 'HASH(0x7fb208b6ac88)', 'is', 'ro') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level/Moose/Meta/Attribute.pm line 83 Moose::Meta::Attribute::interpolate_class_and_new('Moose::Meta::Attribute', 'foo', 'isa', 'DateTime|Undef', 'definition_context', 'HASH(0x7fb208b6ac88)', 'is', 'ro') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level/Moose/Meta/Class.pm line 438 Moose::Meta::Class::_process_new_attribute('Moose::Meta::Class=HASH(0x7fb208c70eb0)', 'foo', 'isa', 'DateTime|Undef', 'definition_context', 'HASH(0x7fb208b6ac88)', 'is', 'ro') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level/Moose/Meta/Class.pm line 431 Moose::Meta::Class::_process_attribute('Moose::Meta::Class=HASH(0x7fb208c70eb0)', 'foo', 'isa', 'DateTime|Undef', 'definition_context', 'HASH(0x7fb208b6ac88)', 'is', 'ro') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level/Moose/Meta/Class.pm line 300 Moose::Meta::Class::add_attribute('Moose::Meta::Class=HASH(0x7fb208c70eb0)', 'foo', 'isa', 'DateTime|Undef', 'definition_context', 'HASH(0x7fb208b6ac88)', 'is', 'ro') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi-2level/Moose.pm line 70 Moose::has('Moose::Meta::Class=HASH(0x7fb208c70eb0)', 'foo', 'is', 'ro', 'isa', 'DateTime|Undef') called at /opt/local/lib/perl5/vendor_perl/5.12.4/darwin-multi- 2level/Moose/Exporter.pm line 359 Moose::has('foo', 'is', 'ro', 'isa', 'DateTime|Undef') called at -e line 1
Subject: Re: [rt.cpan.org #79299] Package is not visible when Moose use DateTime|Undef union
Date: Thu, 30 Aug 2012 09:11:17 -0500 (CDT)
To: Pawel Pabian via RT <bug-DateTime [...] rt.cpan.org>
From: Dave Rolsky <autarch [...] urth.org>
Download (untitled) / with headers
text/plain 538b
On Thu, 30 Aug 2012, Pawel Pabian via RT wrote: Show quoted text
> $ perl -e 'use DateTime; package A; use Moose; has "foo" => ("is" => "ro", "isa" => > "DateTime|Undef"); print "alive\n"'
Add a class_type('DateTime') in there and that fixes it. Whatever's going on has nothing to do with DateTime. -dave /*============================================================ http://VegGuide.org http://blog.urth.org Your guide to all that's veg House Absolute(ly Pointless) ============================================================*/
Download (untitled) / with headers
text/plain 435b
On Thu Aug 30 07:11:28 2012, autarch@urth.org wrote: Show quoted text
> On Thu, 30 Aug 2012, Pawel Pabian via RT wrote: >
> > $ perl -e 'use DateTime; package A; use Moose; has "foo" => ("is" =>
> "ro", "isa" =>
> > "DateTime|Undef"); print "alive\n"'
> > Add a class_type('DateTime') in there and that fixes it.
Moose::Util::TypeConstraints::_create_type_constraint_union could call class_type for strings that are not recognized types. should it?
Subject: Re: [rt.cpan.org #79299] DateTime|Undef constraint fails without predeclaration of DateTime as class_type
Date: Wed, 13 Mar 2013 16:17:40 -0500
To: Karen Etheridge via RT <bug-Moose [...] rt.cpan.org>
From: Jesse Luehrs <doy [...] tozt.net>
On Wed, Mar 13, 2013 at 05:12:54PM -0400, Karen Etheridge via RT wrote: Show quoted text
> Queue: Moose > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=79299 > > > On Thu Aug 30 07:11:28 2012, autarch@urth.org wrote:
> > On Thu, 30 Aug 2012, Pawel Pabian via RT wrote: > >
> > > $ perl -e 'use DateTime; package A; use Moose; has "foo" => ("is" =>
> > "ro", "isa" =>
> > > "DateTime|Undef"); print "alive\n"'
> > > > Add a class_type('DateTime') in there and that fixes it.
> > Moose::Util::TypeConstraints::_create_type_constraint_union could call > class_type for strings that are not recognized types. should it?
This was intentionally not done, because the possibility of the implicit choice being wrong was considered to be a lot higher for unions (especially when you don't have complete test coverage). I'm not really sure of my opinion on it - I do agree with the reasoning behind it, but this issue also does come up a lot. I'd honestly be more inclined to remove the implicit class_type from everywhere else than add it here, but I also don't know how reasonable of an idea that is. -doy
Subject: find_or_parse_type_constraint doesn't assume that unknown types correspond to classes
Download (untitled) / with headers
text/plain 743b
package Foo::Link; use strictures; use Moose qw(has); has("href", is => "rw", isa => "URI | URI::Template",); 1; __END__ Could not locate type constraint (URI) for the union [14:26] <rjbs> Well, my real answer is "screw those string types, use class_type" [14:26] <rjbs> but I'm not sure why the above does not work. [14:27] <rjbs> my guess would be that the union-generating code won't auto-create class types as needed [14:27] <tobyink> Unions use find_or_parse_type_constraint. [14:27] <tobyink> find_or_parse_type_constraint doesn't assume that unknown types corrtespond to classes [14:27] <rjbs> daxim: please bug report, yes [14:27] <tobyink> Only find_or_create_isa_type_constraint makes that assumption.
This is a duplicate of #79299.
reopening to merge.


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.