Closed iynehz closed 1 year ago
I have implemented automatic type coercion in the last commits. Compared to your implementation, there are a few differences:
$tc->can("has_coercion") && $tc->has_coercion
is performed in XS at compile time. Only $tc->coerce($value)
is visible in the generated code.But I think the general gist is the same and it addresses this issue.
If the type constraint object says it supports coercion, we always use it.
If people really want to disable coercion for a particular parameter, they can do:
fun foo ( (MyType->no_coercions) $bar ) {
...;
}
I use this Function::Parameters with Type::Tiny. I know it does not support coercion now. But I wonder if that is possible to implement. Thanks.