# New Ticket Created by Zefram # Please include the string: [perl #126117] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=126117 >
How nice to be able to use a constant declaration to give a local name to a (possibly complex) type: $ ./perl6 -e 'constant T = Int; my T $a = 3; say $a' 3 But because the constant declaration accepts any kind of defining expression, and gives the value a bareword name, it makes it syntactically possible to use something other than a type object as a type constraint. This doesn't work so well: $ ./perl6 -e 'constant T = 3; my T $a; say $a; $a = 3; say $a' 3 Type check failed in assignment to '$a'; expected 'Int' but got 'Int' in block <unit> at -e:1 The error message on assignment is nonsensical, because the types it complains are mismatching are identical. The only value that can be successfully assigned is Nil, which leaves the variable holding the same (default) value. The same effect can be seen without the user making eir own constant declaration by using the predefined constant i. Presumably using a defined value (anything other than a type object) as a type constraint should be a semantic error. -zefram