Skip Menu |
Report information
Id: 126895
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: smls75 [at] gmail.com
Cc:
AdminCc:

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



Subject: Cannot constrain an optional parameter with a subset type
Download (untitled) / with headers
text/plain 618b
Using a subset type as a type constraint for an optional routine parameter, throws an error when that argument is not passed - rather than falling back to the type object. subset A of Str where any <a aa aaa>; sub foo (A $x?) {}; foo; # Constraint type check failed for parameter '$x' In comparison, a subset type constraint on a 'my' variable happily falls back to the type object if the variable is not initialized: subset A of Str where any <a aa aaa>; my A $x; say $x; # (A) (This is rakudo version 2015.11-424-g240b9ae built on MoarVM version 2015.11-34-gc3eea17.)
Download (untitled) / with headers
text/plain 208b
It works when you explicit specify the type object as the default, rather than using ? to make the parameter optional: subset A of Str where any <a aa aaa>; sub foo (A $x = A) {}; foo;
Download (untitled) / with headers
text/plain 151b
This bug is still present in This is Rakudo version 2017.06-251-g23ad2c388 built on MoarVM version 2017.06-91-g146c8fcc implementing Perl 6.c.


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