Moose icon indicating copy to clipboard operation
Moose copied to clipboard

Fix non-Moose union type constraints

Open maxhq opened this issue 4 years ago • 0 comments

It's currently not possible to reference non-Moose classes in union types if Moose has not yet registered the type constraints. I.e. this works:

has 'bar' => (is => 'rw', isa => 'TestAlgoAA');
has 'baz' => (is => 'rw', isa => 'TestAlgoBB');

but this doesn't:

has 'bar' => (is => 'rw', isa => 'TestAlgoAA | TestAlgoBB');
# Could not locate type constraint (TestAlgoAA) for the union

The cause is the current logic of type parsing / lookup Moose::Util::TypeConstraints. I fixed it by slightly shifting functionality and extending some methods.

Tests are passing. I will try and run test-my-dependents.t on a decent machine soon and post the results.

maxhq avatar Sep 17 '21 22:09 maxhq