-
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Types pre-declaration using declare keyword not possible with Type::Tiny v2 #15
Comments
Remembering this similar issue from 2020 on RT. |
Yeah, I've encountered a similar error myself and been meaning to fix it. A workaround for now is to do this somewhere near the top of your code: BEGIN {
package Test::Keyword::Declare::Types;
use Type::Library -base;
}; |
Thanks. |
Another question I have, which is probably just me being bad. I have two files, a use Zydeco declare => [qw(Character)];
BEGIN { # https://github.com/tobyink/p5-zydeco/issues/15
package Game::Types;
use Type::Library -base;
}
class Character { ... } Then, a use Game; # I tried this but it didn't change anything: qw/:types/;
use Zydeco;
BEGIN { # https://github.com/tobyink/p5-zydeco/issues/15
package Data::Types;
use Type::Library -base, -extends => [ 'Game::Types' ]; # !!! THIS IS NECESSARY
}
class Updater {
has characters ( is => ro, type => ArrayRef[Game::Character] );
method with_char(Character $char) = ...;
} The I'm a bit at a loss for explanations right now, it's probably something to do with the way Zydeco is built but I'm not good enough with Perl to understand. I did realize however, that fields did not go through Anyway, thanks for the great library :). |
Zydeco's
declare
keyword cannot be used with v2 of Type::Tiny anymore, for pre-declaration of types allowing to use them as barewords:perl -c test_keyword_declare.pl
would throw the following message:The error seems to be thrown by
Type::Tiny::_DeclaredType
. I realized it after deploying a new version of theArt::World
module without upgrading libraries locally, but tests failed on CPAN Testers withType::Tiny
v2.If we quote the type, not using the pre-declaration feature, the module compile normally:
The text was updated successfully, but these errors were encountered: