Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix non-Moose union type constraints #180

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

maxhq
Copy link
Contributor

@maxhq maxhq commented Sep 17, 2021

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant