Skip to content
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

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

Open
djerius opened this issue Nov 10, 2023 · 1 comment
Open

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

djerius opened this issue Nov 10, 2023 · 1 comment

Comments

@djerius
Copy link
Contributor

djerius commented Nov 10, 2023

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 djerius changed the title Incorrect API docs for Type::Tiny::constraint_generator Incorrect API docs for Type::Tiny::coercion_generator Nov 10, 2023
@djerius
Copy link
Contributor Author

djerius commented Nov 10, 2023

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

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

No branches or pull requests

1 participant