tobyink / p5-type-tiny

Perl 5 distribution Type-Tiny; see homepage for downloads and documentation.
https://typetiny.toby.ink/
54 stars 48 forks source link

`use Type::Library -declare` without `-base` should result in an error #119

Closed djerius closed 2 years ago

djerius commented 2 years ago

Howdy, Tested under 1.999006, 1.016000

The following code:

package My::Types;

use strict;
use warnings;

use Type::Library -declare => 'ucdType';
use Types::Standard  qw( Any );

use Type::Utils -all;

declare ucdType,
  as Any;

results in the mysterious error:

Can't locate object method "get_type" via package "My::Types" at lib/Type/Library.pm line 142.

Passing the type to declare as a string rather than the predeclared type reveals the error:

"ucdType" is not a valid type name at dev/types_error.pm line 11.
djerius commented 2 years ago

User error. forgot '-base'. Please disregard.

tobyink commented 2 years ago

Hmm, still an interesting case.

I guess -declare without -base/-extends should result in an error.

djerius commented 2 years ago

Bit of a head-scratcher. Reused some code which used -extends, removed the -extends having forgotten that it implicitly provides -base, and boom.

tobyink commented 2 years ago

1.999_008 should include a fix for this

djerius commented 2 years ago

Thanks!