Skip Menu |
Report information
Id: 129889
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: bobn [at] ieee.org
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Sat, 15 Oct 2016 18:36:56 -0700
From: Bob Newgard <bobn [...] ieee.org>
Subject: [BUG] Constraint type check failed for Array parameter
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 1.2k
This works OK (copied from https://docs.perl6.org/language/list#Typing): perl6 -e 'sub mean(Int @a) {@a.sum / @a.elems} ; my Int @b = 1, 3, 5; say mean(@b);' These do not: % perl6 -e 'sub mean(UInt @a) {@a.sum / @a.elems} ; my UInt @b = 1, 3, 5; say mean(@b);' Constraint type check failed for parameter '@a' in sub mean at -e line 1 in block <unit> at -e line 1 % % perl6 -e 'subset Data of UInt where * < 2**32 ; sub mean(Data @a) {@a.sum / @a.elems} ; my Data @b = 1, 3, 5; say mean(@b);' Constraint type check failed for parameter '@a' in sub mean at -e line 1 in block <unit> at -e line 1 % Environment: % perl6 --version This is Rakudo version 2016.06 built on MoarVM version 2016.06 implementing Perl 6.c. % uname -a Linux host 4.7.0-1-amd64 #1 SMP Debian 4.7.5-1 (2016-09-26) x86_64 GNU/Linux % dpkg-ck rakudo Desired=Unknown/Install/Remove/Purge/Hold | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad) ||/ Name Version +++-================================================-=========================== ii rakudo 2016.06-1 ii rakudo-lib 2016.06-1
Download (untitled) / with headers
text/plain 446b
Slightly golfed on 2016.09-200-g2c681c5: $ ./perl6 -e 'sub (Int @) {}(my Int @b)' $ ./perl6 -e 'sub (Int @) {}(my UInt @b)' $ ./perl6 -e 'sub (UInt @) {}(my UInt @b)' Constraint type check failed for parameter '<anon>' in sub at -e line 1 in block <unit> at -e line 1
Download (untitled) / with headers
text/plain 162b
And subsets that don't involve UInt seem to work fine: $ ./perl6 -e 'subset Foo; sub (Foo @) {}(my UInt @b)' $ ./perl6 -e 'subset Foo; sub (Foo @) {}(my Foo @b)'
Date: Sun, 16 Oct 2016 11:17:36 -0400
From: Parrot Raiser <1parrota [...] gmail.com>
To: perl6-compiler [...] perl.org
Subject: Re: [perl #129889] [BUG] Constraint type check failed for Array parameter
FWIW, that's true on 2016.07.01 as well. build-date = 2016-07-22T12:37:00Z
Download (untitled) / with headers
text/plain 216b
Note the type must have a constraint: $ perl6 -e 'subset Foo of Int where * > 1; sub f(Foo @i){}; f(my Foo @a);' Constraint type check failed for parameter '@i' in sub f at -e line 1 in block <unit> at -e line 1


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org