Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

function prototypes using array of subset type give type error #6279

Open p6rt opened 7 years ago

p6rt commented 7 years ago

Migrated from rt.perl.org#131381 (status was 'new')

Searchable as RT131381$

p6rt commented 7 years ago

From danielcliffordmiller@gmail.com

This is Rakudo version 2017.04.3 built on MoarVM version 2017.04-53-g66c6dda

implementing Perl 6.c

p6rt commented 7 years ago

From danielcliffordmiller@gmail.com

test.pl6

p6rt commented 7 years ago

From @zoffixznet

OP's code in the attachment​:

subset PositiveInt of Int where * > 0;

my Int $i = 4; my Int @​i = (2,4);

my PositiveInt $p = 6; my PositiveInt @​p = (2,4);

sub handle-ints (Int @​i) {} sub handle-positive-ints (PositiveInt @​p) {}

$i = -5; #$p = -5; # should fail

handle-ints(@​i); #handle-ints( (2.2, 1.1) ); # should fail

handle-positive-ints(@​p); # this fails?

p6rt commented 7 years ago

From @zoffixznet

Golfed version​:

m​: -> UInt @​ {}(Array[UInt].new) rakudo-moar 8ec181​: OUTPUT​: «Constraint type check failed in binding to parameter '\'; expected UInt but got Array[UInt] (Array[UInt].new())␤ in block \ at \ line 1␤␤»

Works if you don't use `@​` sigil​:

m​: -> Positional[UInt] {}(Array[UInt].new) rakudo-moar 8ec181​: ( no output )

p6rt commented 7 years ago

From @zoffixznet

Fudged test added​: https://github.com/perl6/roast/pull/273