Subject: | Tuple validation unexpectedly successful |
The following validation passes:
sub test1 {
state $check = compile( Tuple[Any, Any] );
my ($arg) = $check->(@_);
}
test1( [1, undef] ); # pass - as expected
test1( [1] ) # pass - unexpected because no 2nd element
I'm not sure if this was the intended behaviour but it was unexpected to me. I understand that `Any` accepts undefs, and we can get the expected behaviour if we change `Any` to `Defined`.
Here's another example as a parallel with different behaviour:
sub test2 {
state $check = compile( Any, Any );
my $arg = [ $check->(@_) ];
}
test2( 1, undef ); # pass - as expected
test2( 1 ); # FAIL - as expected
This second example makes more sense to me, and the first example has behaviour that is inconsistent with it.