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

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

Open
p6rt opened this issue May 27, 2017 · 5 comments
Open

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

p6rt opened this issue May 27, 2017 · 5 comments
Labels

Comments

@p6rt
Copy link

@p6rt p6rt commented May 27, 2017

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

Searchable as RT131381$

@p6rt
Copy link
Author

@p6rt p6rt commented May 27, 2017

From danielcliffordmiller@gmail.com

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

implementing Perl 6.c

@p6rt
Copy link
Author

@p6rt p6rt commented May 27, 2017

@p6rt
Copy link
Author

@p6rt p6rt commented Jun 1, 2017

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
Copy link
Author

@p6rt p6rt commented Jun 1, 2017

From @zoffixznet

Golfed version​:

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

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

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

@p6rt
Copy link
Author

@p6rt p6rt commented Jun 1, 2017

From @zoffixznet

Fudged test added​: Raku/roast#273

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant