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

Incorrect API docs for Type::Tiny::coercion_generator #148

Open djerius opened 1 year ago

djerius commented 1 year ago

The docs for Type::Tiny::constraint_generator state:

Coderef that is called when a type constraint is parameterized. When called, it is passed the list of parameters,

And the docs for Type::Tiny::coercion_generator state:

Called with the same parameters and package variables as the "constraint_generator".

However, it's actually called as

$code->( $self, $child_type, @args )

I.E.

   1163                         $P = $self->create_child_type( %options );
   1164                         
   1165                         if ( $self->has_coercion_generator ) {
   1166                                 my @args = @_;
   1167                                 $P->{_build_coercion} = sub {
   1168                                         my $coercion = shift;
   1169                                         my $built    = $self->coercion_generator->( $self, $P, @args );
   1170                                         $coercion->add_type_coercions( @{ $built->type_coercion_map } ) if $built;
   1171                                         $coercion->freeze;
   1172                                 };
   1173                         }
djerius commented 1 year ago

Mistake in title (fixed): it's coercion_generator, not constraint_generator.