# New Ticket Created by  Timothy Bollman 
# Please include the string:  [perl #130246]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=130246 >


If you create a typed array attribute for a class and then attempt to assign it 
in the constructor using a hash slip, it fails type validation.


Error message: Type check failed in assignment to @!b; expected Str but got 
Array ($["a", "b", "c"])


use v6;
use Test;

plan 8;
class A {
    has @.b;
}
class A-validate {
    has Str @b;
}
my $a;
my @b = <a b c>;
my %attr = (b => @b);
lives-ok { $a = A.new(b => @b) }, 'A Created';
is($a.b, @b, 'A.b valid');
lives-ok { $a = A.new(|%attr) }, 'A created (slip)';
is($a.b, @b, 'A.b valid (slip)');
lives-ok { $a = A-validate.new(b => @b) }, 'A Created (validate)';
is($a.b, @b, 'A.b valid (validate)');
lives-ok { $a = A-validate.new(|%attr) }, 'A created (validate, slip)'; # fails
is($a.b, @b, 'A.b valid (validate, slip)');


Thanks,

Tim Bollman

Reply via email to