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

empty string expected when tying an undefined variable to a Str type constraint #152

Open
XSven opened this issue Dec 28, 2023 · 0 comments

Comments

@XSven
Copy link

XSven commented Dec 28, 2023

I am expecting both tests to pass. Unfortunately the empty string test is failing.

use Test::More tests => 2;

use Type::Tie       qw( ttie );
use Types::Standard qw( Num Str );

ttie my @n, Num;
is_deeply \@n, [], 'empty list';

ttie my $s, Str;
is $s, '', 'empty string';

From my perspective, a proper initial value ("zero" value in golang terminology) should be assigned to an undefined scalar variable. The value has to honour the type constraint. Maybe Type::Tie::SCALAR::_DEFAULT has to depend on the type constraint.

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