Skip Menu |
 

This queue is for tickets about the Catalyst-Runtime CPAN distribution.

Report information
The Basics
Id: 124616
Status: new
Priority: 0/
Queue: Catalyst-Runtime

People
Owner: Nobody in particular
Requestors: m [...] frausing.me
Cc:
AdminCc:

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



Subject: Trying Composite Moose roles for resolving type constraints in Args
Download (untitled) / with headers
text/plain 1.6k
Hi This is related to #104451, but I don't think it is the same problem hence the new ticket. After upgrading to 5.90103 (Ubuntu 16.04) I get: Str, Enum[qw/small medium large/] is not a constraint! at lib/perl5/Catalyst/Action.pm line 158 The problem isn't the syntax, namespace::autoclean or not including Types::Standard. The code worked before the upgrade to Catalyst 5.90103. I have also tried older Catalyst (5.90100) with the newest Moose (2.2010) without problems, whereas 5.90103 with the same Moose gave me the above problem. The bug is caused by the way Catalyst tries to resolve the type constraints: my @tc = eval "package ${\$parent->name}; $name"; This works fine for Roles, but for Moose::Meta::Role::Composite the name is: $params{name} ||= (join "|" => map { $_->name } @{$params{roles}}) Which of course doesn't apply well to the above eval. The code for resolve_type_constraint is similar in all three versions of Catalyst of I have tested, but "$self->class->meta->calculate_all_roles" returns different role compositions. In my code in older Catalysts the module using type constraints was not in a composite and therefore could be resolved successfully. If resolve_type_constraint finds a method with Args and a type constraint that matches what we try to resolve it stops and therefore doesn't try some of the non Composite roles which is also found by "calculate_all_roles". A solution is to disregard Role::Composites: - my @roles = $self->class->can('meta') ? $self->class->meta->calculate_all_roles : (); + my @roles = grep { !$_->isa('Moose::Meta::Role::Composite') } $self->class->can('meta') ? $self->class->meta->calculate_all_roles : (); that make it work for me.
Subject: action.pm.patch
Download action.pm.patch
text/x-diff 644b
--- Action.pm.orig 2018-02-28 07:52:56.407726261 +0100 +++ Action.pm 2018-02-28 07:53:11.543924651 +0100 @@ -270,7 +270,7 @@ # Superclasses take precedence; my @supers = $self->class->can('meta') ? map { $_->meta } $self->class->meta->superclasses : (); - my @roles = $self->class->can('meta') ? $self->class->meta->calculate_all_roles : (); + my @roles = grep { !$_->isa('Moose::Meta::Role::Composite') } $self->class->can('meta') ? $self->class->meta->calculate_all_roles : (); # So look through all the super and roles in order and return the # first type constraint found. We should probably find all matching


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.