Skip Menu |

This queue is for tickets about the MooseX-Types CPAN distribution.

Report information
The Basics
Id: 46891
Status: resolved
Priority: 0/
Queue: MooseX-Types

People
Owner: Nobody in particular
Requestors: perl [...] evancarroll.com
Cc:
AdminCc:

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



Subject: Just dies.
This release seems to be a total lemon for many reasons. I can pinpoint them -- I'd implore you to test this further. It is definitly //not// backwards compatible with .10
Subject: Drawbacks of .11
Ok, first I wanted to confirm this stuff. CPANPLUS was being mega shitass, and I just filed a bug on it too for failing to downgrade by url. So the deal is, in .10, the following code works: package Foo; use MooseX::Types; subtype "foo" => as "Int"; subtype "bar" => as "foo"; However, in .11 you can't write it the same way, that same code gives you this. WARNING: String found where Type expected (did you use a => instead of a , ?) at -e line 1 WARNING: String found where Type expected (did you use a => instead of a , ?) at -e line 1 WARNING: String found where Type expected (did you use a => instead of a , ?) at -e line 1 WARNING: String found where Type expected (did you use a => instead of a , ?) at -e line 1 Logically, you've made the types consistent on Barewords (I strongly would have preferred a string solution for consistency, but whatever). So I try to remove the strings, and the fat commas. package Foo; use MooseX::Types; subtype foo , as Int; subtype bar , as foo; But nothing is in your package, so you have MooseX::Types::Moose pollute you with the Int, and now, new to .10 you have to declare things even if they aren't exported (as in internal base types).. so you try package Foo; use MooseX::Types::Moose qw(Int); use MooseX::Types -declare qw(foo bar); subtype foo , as Int; subtype bar , as foo; Finally, you have joy -- kinda, this begs the question on how you declare an unexported base type. You think you've got it, but still no joy. Now with .11 Roles that where composed into classes that used the MX::Types library have to also use the MX::Types library -- this might be a good thing, but it certainly isn't backwards compat. So you go back and look at your code add the missing includes for the Types and save and try again. Does it work yet? Nope, because now that you're using Barewords you have to use Explicitly code all of the variables into Sub::Exporter, whereas in .10 you you could use strings, and thus only had to put the subs you wanted exported too in Sub::Exporter... So finally, after you've got rid off all of the stringifications with quotes and fat commas, and you've replaced all base types with MooseX::Types::Moose barewords, and you updated Sub::Exporter to export all of those barewords now... You ask the question, do I have joy yet? Nope. And, why is that you ask.. Could not load class (DM::IO::Input::File) because : Could not load class (DM::IO::Input::Base::Index) because : Could not locate type constraint (Money) for the union at /usr/local/share/perl/5.10.0/Moose/Util/TypeConstraints.pm line 87 Fuck! A 2 month old critical bug on rt was less important than this? Jesus. Christ. So now I can't use a type-union with MooseX::Types and Undef. package Foo; use MooseX::Types::Moose qw(Int); use MooseX::Types -declare => [qw(foo bar)]; subtype foo , as Int; subtype bar , as foo; package WTF; use Moose; Foo->import( 'foo', 'bar' ); ## No workie has 'mutatedtype' => ( isa => 'foo | Undef', is => 'rw' ); ## workie has 'mutatedtype' => ( isa => 'foo', is => 'rw' ); This used to work before, not being able to do this is going to prevent successful migration to .11. At least before I could use the global-string-types version and get this working. As as a side note the docs for migration are really needed here, I really had to like 4 steps to get this to even `perl -c` with .11.
Subject: Re: [rt.cpan.org #46891] Drawbacks of .11
Date: Fri, 12 Jun 2009 12:02:40 -0700 (PDT)
To: bug-MooseX-Types [...] rt.cpan.org
From: John Napiorkowski <jjn1056 [...] yahoo.com>
Evan, I want to take these problems seriously, since it's clear to me that some of these changes break things that should work. However, some thing that passed (but silently failed to do anything useful) are now breaking loudly. So we need to detangle all this and build up some test cases we can crank against. Specific comments follow: --- On Fri, 6/12/09, Evan Carroll via RT <bug-MooseX-Types@rt.cpan.org> wrote: Show quoted text
> From: Evan Carroll via RT <bug-MooseX-Types@rt.cpan.org> > Subject: [rt.cpan.org #46891] Drawbacks of .11 > To: > Date: Friday, June 12, 2009, 2:20 PM >     >    Queue: MooseX-Types > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=46891 > > > Ok, first I wanted to confirm this stuff. CPANPLUS was > being mega > shitass, and I just filed a bug on it too for failing to > downgrade by url. > > So the deal is, in .10, the following code works: > package Foo; > use MooseX::Types; > subtype "foo" => as "Int"; > subtype "bar" => as "foo";
Yes, now when you load MooseX::Types the subtype method is getting intercepted so declaring global string based stuff is not working anymore. This is a side effect of trying to solve the problem of people incorrectly stringifying the subtype name by using => over ,. Unfortunately this error is one of the more common ones with MX::Types and it too often is silently failing. A core assumption here is that if you are using MX:Types you intend to use it and not mix and match global string types. We can make that a point of discussion. Show quoted text
> > However, in .11 you can't write it the same way, that same > code gives > you this. > WARNING: String found where Type expected (did you use a > => instead of a > , ?) at -e line 1 > WARNING: String found where Type expected (did you use a > => instead of a > , ?) at -e line 1 > WARNING: String found where Type expected (did you use a > => instead of a > , ?) at -e line 1 > WARNING: String found where Type expected (did you use a > => instead of a > , ?) at -e line 1 > > Logically, you've made the types consistent on Barewords (I > strongly > would have preferred a string solution for consistency, but > whatever). > So I try to remove the strings, and the fat commas. > package Foo; > use MooseX::Types; > subtype foo , as Int; > subtype bar , as foo; > > But nothing is in your package, so you have > MooseX::Types::Moose pollute > you with the Int, and now, new to .10 you have to declare > things even if > they aren't exported (as in internal base types).. so you > try > package Foo; > use MooseX::Types::Moose qw(Int); > use MooseX::Types -declare qw(foo bar); > subtype foo , as Int; > subtype bar , as foo;
Yes, I think you should be able to use the old string stuff in the 'as' clause. However, this was probably silently failing on you, since the "as 'Int'" would be meaningly without 'use Moose'. So my guess in that case you'd not get a failure but the type constraint library was failing to do anything useful. Show quoted text
> > Finally, you have joy -- kinda, this begs the question on > how you > declare an unexported base type. You think you've got it, > but still no > joy. Now with .11 Roles that where composed into classes > that used the > MX::Types library have to also use the MX::Types library -- > this might > be a good thing, but it certainly isn't backwards compat. > So you go back > and look at your code add the missing includes for the > Types and save > and try again. Does it work yet? Nope, because now that > you're using > Barewords you have to use Explicitly code all of the > variables into > Sub::Exporter, whereas in .10 you you could use strings, > and thus only > had to put the subs you wanted exported too in > Sub::Exporter... >
More test cases with roles are called for. However I would imagine my previous comment about "it used to work" stands. It probably failed to warn or throw an error before, but it probably wasn't constraining anything. Show quoted text
> So finally, after you've got rid off all of the > stringifications with > quotes and fat commas, and you've replaced all base types > with > MooseX::Types::Moose barewords, and you updated > Sub::Exporter to export > all of those barewords now... You ask the question, do I > have joy yet? > Nope. And, why is that you ask.. > > Could not load class (DM::IO::Input::File) because : Could > not load > class (DM::IO::Input::Base::Index) because : Could not > locate type > constraint (Money) for the union at > /usr/local/share/perl/5.10.0/Moose/Util/TypeConstraints.pm > line 87 > > Fuck! A 2 month old critical bug on rt was less important > than this? > Jesus. Christ. So now I can't use a type-union with > MooseX::Types and Undef. > > package Foo; > use MooseX::Types::Moose qw(Int); > use MooseX::Types -declare => [qw(foo bar)]; > subtype foo , as Int; > subtype bar , as foo; > > package WTF; > use Moose; > Foo->import( 'foo', 'bar' ); > > ## No workie > has 'mutatedtype' => ( isa => 'foo | Undef', is => > 'rw' ); > ## workie > has 'mutatedtype' => ( isa => 'foo', is => 'rw' > ); > > > This used to work before, not being able to do this is > going to prevent > successful migration to .11.
Well, again, the above would have not constrained anything. in this case 'foo' is nothing. You could do isa=> Foo|Undef isa=> Maybe[Foo] Undef and Maybe you can import from MooseX::Types::Moose qw(Undef Maybe) Show quoted text
> At least before I could use > the > global-string-types version and get this working. > > As as a side note the docs for migration are really needed > here, I > really had to like 4 steps to get this to even `perl -c` > with .11. >
Docs would probably be usefull. The core issue here is that people were improperly using this stuff and getting silent fails. Now they are getting loud fails. Also, some stuff is failing that probably should work. We need to detangle it all. Thanks for the thoughts and the detailed report.
Well, I'm not sure I can adequately refute this as my interest in moose and perl has declined rapidly since my kline from irc.perl.org, but I'll give it a try. Show quoted text
> Well, again, the above would have not constrained anything. in this > case 'foo' is nothing. > > You could do > > isa=> Foo|Undef > isa=> Maybe[Foo] > > Undef and Maybe you can import from MooseX::Types::Moose qw(Undef > Maybe)
Maybe[Foo], and Foo|Undef have historically had massively different coercion implications. Maybe[Foo] says, it is a Foo, or is an undef, and you must coerce from 'Maybe[Foo]', and not Foo., this makes the already cumbersome Coercions of MX::Types even more nonsensical, because to have a Maybe[Foo], a Maybe[Foo|Bar], and a Maybe[Foo|Bar|Baz] you would have to write coercions for three parameterized types. A type union, historically, was implemented totally different. Foo|Undef, Foo|Bar|Undef, Foo|Bar|Baz|Undef; (spaces padding '|' don't matter, in fact I filed the bug when they were required to make them accepted again). In this form, you're saying coerce to foo, if you can't, coerce to Bar, if you can't coerce to Baz, if you can't and you're Undef then good, else fail. Jnaporisaisdfkoekf or whatever his name is knows more about the theory behind this stuff. He had a solution to the subpar coercive abilities of MX:T that he was working on with facets, but I'm not sure how far he got.
Subject: Re: [rt.cpan.org #46891] Drawbacks of .11
Date: Fri, 12 Jun 2009 15:38:07 -0700
To: Evan Carroll via RT <bug-MooseX-Types [...] rt.cpan.org>
From: Rafael Kitover <rkitover [...] io.com>
Hey EC, For making base types that are not exported, you can do: package Foo; use MooseX::Types -declare => ['Bar']; use MooseX::Types::Moose 'Int'; subtype 'Foo::Base', as Int; subtype Bar, as 'Foo::Base'; fully qualified and namespaced types will work fine. You should not be making global types as your base types any way. Will add docs about this. On Fri, Jun 12, 2009 at 02:20:08PM -0400, Evan Carroll via RT wrote: Show quoted text
> Queue: MooseX-Types > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=46891 > > > Ok, first I wanted to confirm this stuff. CPANPLUS was being mega > shitass, and I just filed a bug on it too for failing to downgrade by url. > > So the deal is, in .10, the following code works: > package Foo; > use MooseX::Types; > subtype "foo" => as "Int"; > subtype "bar" => as "foo"; > > However, in .11 you can't write it the same way, that same code gives > you this. > WARNING: String found where Type expected (did you use a => instead of a > , ?) at -e line 1 > WARNING: String found where Type expected (did you use a => instead of a > , ?) at -e line 1 > WARNING: String found where Type expected (did you use a => instead of a > , ?) at -e line 1 > WARNING: String found where Type expected (did you use a => instead of a > , ?) at -e line 1 > > Logically, you've made the types consistent on Barewords (I strongly > would have preferred a string solution for consistency, but whatever). > So I try to remove the strings, and the fat commas. > package Foo; > use MooseX::Types; > subtype foo , as Int; > subtype bar , as foo; > > But nothing is in your package, so you have MooseX::Types::Moose pollute > you with the Int, and now, new to .10 you have to declare things even if > they aren't exported (as in internal base types).. so you try > package Foo; > use MooseX::Types::Moose qw(Int); > use MooseX::Types -declare qw(foo bar); > subtype foo , as Int; > subtype bar , as foo; > > Finally, you have joy -- kinda, this begs the question on how you > declare an unexported base type. You think you've got it, but still no > joy. Now with .11 Roles that where composed into classes that used the > MX::Types library have to also use the MX::Types library -- this might > be a good thing, but it certainly isn't backwards compat. So you go back > and look at your code add the missing includes for the Types and save > and try again. Does it work yet? Nope, because now that you're using > Barewords you have to use Explicitly code all of the variables into > Sub::Exporter, whereas in .10 you you could use strings, and thus only > had to put the subs you wanted exported too in Sub::Exporter... > > So finally, after you've got rid off all of the stringifications with > quotes and fat commas, and you've replaced all base types with > MooseX::Types::Moose barewords, and you updated Sub::Exporter to export > all of those barewords now... You ask the question, do I have joy yet? > Nope. And, why is that you ask.. > > Could not load class (DM::IO::Input::File) because : Could not load > class (DM::IO::Input::Base::Index) because : Could not locate type > constraint (Money) for the union at > /usr/local/share/perl/5.10.0/Moose/Util/TypeConstraints.pm line 87 > > Fuck! A 2 month old critical bug on rt was less important than this? > Jesus. Christ. So now I can't use a type-union with MooseX::Types and Undef. > > package Foo; > use MooseX::Types::Moose qw(Int); > use MooseX::Types -declare => [qw(foo bar)]; > subtype foo , as Int; > subtype bar , as foo; > > package WTF; > use Moose; > Foo->import( 'foo', 'bar' ); > > ## No workie > has 'mutatedtype' => ( isa => 'foo | Undef', is => 'rw' ); > ## workie > has 'mutatedtype' => ( isa => 'foo', is => 'rw' ); > > > This used to work before, not being able to do this is going to prevent > successful migration to .11. At least before I could use the > global-string-types version and get this working. > > As as a side note the docs for migration are really needed here, I > really had to like 4 steps to get this to even `perl -c` with .11.
What are you randomly closing bugs for? If you don't understand this module you should pass maintainership. How do you make vanilla.t work in MX::Types now that you've removed the global string types.... (failing test mxtypes.t) Now, downgrade your MX::Types to 0.08 (probably works with a slightly newer version too), check out old_mxtypes.t, !!! See it works. You not just massively broke backwards compat, but you deprived us of an important function -- Coercions in Unions, please fix.
package Class; use Moose; use Moose::Util::TypeConstraints; subtype "CoercedType" , as "Str" , where { $_ !~ /foo/ } , message { "Fuck foo" } ; coerce "CoercedType" , from "Str" , via { s/foo/bar/, $_ } ; has 'attr' => ( isa => 'CoercedType | Undef' , is => 'rw' , coerce => 1 ); package main; use Test::More "tests" => 2; my $c = Class->new; $c->attr( 'foo' ); is( $c->attr, 'bar' ); $c->attr( undef ); is( $c->attr, undef );
package Types; use MooseX::Types -declare => [qw/ CoercedType /]; use MooseX::Types::Moose qw( Str ); subtype CoercedType , as Str , where { $_ !~ /foo/ } , message { "Fuck foo" } ; coerce CoercedType , from Str , via { s/foo/bar/, $_ } ; package Class; use Moose; BEGIN{ Types->import(qw/CoercedType/); } has 'attr' => ( isa => 'CoercedType | Undef' , is => 'rw' , coerce => 1 ); package main; use Test::More tests => 2; my $c = Class->new; $c->attr( 'foo' ); is( $c->attr, 'bar' ); $c->attr( undef ); is( $c->attr, undef );
package Types; use MooseX::Types -declare => [qw/ CoercedType /]; use MooseX::Types::Moose qw( Str ); subtype "CoercedType" , as Str , where { $_ !~ /foo/ } , message { "Fuck foo" } ; coerce "CoercedType" , from Str , via { s/foo/bar/, $_ } ; package Class; use Moose; BEGIN{ Types->import(qw/CoercedType/); } has 'attr' => ( isa => 'CoercedType | Undef' , is => 'rw' , coerce => 1 ); package main; use Test::More tests => 2; my $c = Class->new; $c->attr( 'foo' ); is( $c->attr, 'bar' ); $c->attr( undef ); is( $c->attr, undef );
Subject: Re: [rt.cpan.org #46891] Many bugs in .11 -- no mention of upgrade method, no work around for 44749
Date: Sat, 27 Jun 2009 12:39:01 -0700
To: Evan Carroll via RT <bug-MooseX-Types [...] rt.cpan.org>
From: Rafael Kitover <rkitover [...] io.com>
mxtypes.t fails on both 0.08 and 0.14 You need to use either: isa => CoercedType | Undef # no quotes or isa => 'Types::CoercedType | Undef' then the test passes. old_mxtypes.t and vanilla.t pass on both 0.08 and 0.14 On Sat, Jun 27, 2009 at 01:36:31PM -0400, Evan Carroll via RT wrote: Show quoted text
> Queue: MooseX-Types > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=46891 > > > What are you randomly closing bugs for? If you don't understand this > module you should pass maintainership. > > How do you make vanilla.t work in MX::Types now that you've removed the > global string types.... (failing test mxtypes.t) > > Now, downgrade your MX::Types to 0.08 (probably works with a slightly > newer version too), check out old_mxtypes.t, !!! See it works. > > You not just massively broke backwards compat, but you deprived us of an > important function -- Coercions in Unions, please fix.
Show quoted text
> package Class; > use Moose; > use Moose::Util::TypeConstraints; > > subtype "CoercedType" > , as "Str" > , where { $_ !~ /foo/ } > , message { "Fuck foo" } > ; > > coerce "CoercedType" > , from "Str" > , via { s/foo/bar/, $_ } > ; > > has 'attr' => ( > isa => 'CoercedType | Undef' > , is => 'rw' > , coerce => 1 > ); > > package main; > use Test::More "tests" => 2; > my $c = Class->new; > $c->attr( 'foo' ); > is( $c->attr, 'bar' ); > > $c->attr( undef ); > is( $c->attr, undef ); >
Show quoted text
> package Types; > use MooseX::Types -declare => [qw/ CoercedType /]; > use MooseX::Types::Moose qw( Str ); > > subtype CoercedType > , as Str > , where { $_ !~ /foo/ } > , message { "Fuck foo" } > ; > > coerce CoercedType > , from Str > , via { s/foo/bar/, $_ } > ; > > package Class; > use Moose; > > BEGIN{ Types->import(qw/CoercedType/); } > > has 'attr' => ( > isa => 'CoercedType | Undef' > , is => 'rw' > , coerce => 1 > ); > > package main; > use Test::More tests => 2; > my $c = Class->new; > $c->attr( 'foo' ); > is( $c->attr, 'bar' ); > > $c->attr( undef ); > is( $c->attr, undef ); > >
Show quoted text
> package Types; > use MooseX::Types -declare => [qw/ CoercedType /]; > use MooseX::Types::Moose qw( Str ); > > subtype "CoercedType" > , as Str > , where { $_ !~ /foo/ } > , message { "Fuck foo" } > ; > > coerce "CoercedType" > , from Str > , via { s/foo/bar/, $_ } > ; > > package Class; > use Moose; > > BEGIN{ Types->import(qw/CoercedType/); } > > has 'attr' => ( > isa => 'CoercedType | Undef' > , is => 'rw' > , coerce => 1 > ); > > package main; > use Test::More tests => 2; > my $c = Class->new; > $c->attr( 'foo' ); > is( $c->attr, 'bar' ); > > $c->attr( undef ); > is( $c->attr, undef ); > >
Thanks for help, can you make changes to the tests and commit them?
I think we can close this now?