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

Owner: Nobody
Requestors: zefram [at]

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

Subject: [BUG] defined value as type constraint has inconsistent behaviour
From: Zefram <zefram [...]>
Date: Sun, 13 Dec 2015 23:48:40 +0000
To: rakudobug [...]
Download (untitled) / with headers
text/plain 609b
If a defined value is used as a type constraint, the values that the constraint will accept are inconsistent between using the type constraint on a variable and using it on a sub parameter: Show quoted text
> constant T = 3
3 Show quoted text
> 3.^isa(T)
0 Show quoted text
> (sub (T $a) { 1 })(3)
1 Show quoted text
> my T $a = 3
Type check failed in assignment to $a; expected 3 but got 3 in block <unit> at <unknown file>:1 The two type constraint situations are consistent in disallowing other values such as 2, "foo", and Int. It probably should not be permitted at all to use anything other than a type object as a type constraint. See also [perl #126117]. -zefram

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

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