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

Constraint type check failed for Array parameter #5751

Open
p6rt opened this issue Oct 16, 2016 · 6 comments
Open

Constraint type check failed for Array parameter #5751

p6rt opened this issue Oct 16, 2016 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 16, 2016

Migrated from rt.perl.org#129889 (status was 'open')

Searchable as RT129889$

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From bobn@ieee.org

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

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From @zoffixznet

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

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From @zoffixznet

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)'

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

From 1parrota@gmail.com

FWIW, that's true on 2016.07.01 as well. build-date = 2016-07-22T12​:37​:00Z

@p6rt
Copy link
Author

p6rt commented Oct 16, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 18, 2016

From ctp@fastmail.co.uk

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

@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
Development

No branches or pull requests

1 participant