# New Ticket Created by Zefram # Please include the string: [perl #128407] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=128407 >
The Scalar:D type constraint doesn't work on a variable: > my $v = 3 > my $s = $v.VAR > $s.WHAT.say (Scalar) > $s.DEFINITE True > my Scalar:D $x = $s Type check failed in assignment to $x; expected Scalar:D but got Int (3) in block <unit> at <unknown file> line 1 $s is a defined Scalar object, so should satisfy the Scalar:D type constraint, but it is being rejected. The error message erroneously refers to the value contained in the Scalar. As this suggests, if the Scalar happens to contain a defined Scalar object (such as by "$v = $s"), then the variable initialisation succeeds. The same goes for assignments to the Scalar:D variable after successful creation: the assignment is permitted iff the value being assigned is a defined Scalar that contains a defined Scalar value (regardless of the value contained in the inner Scalar). A Scalar:D type constraint on a subroutine parameter works fine: it accepts a value iff the value is a defined Scalar (regardless of the value that the Scalar contains). -zefram
