# New Ticket Created by  Dagfinn Ilmari Mannsåker 
# Please include the string:  [perl #126296]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=126296 >


Or to put another way: attributes with 'is required' should not need an
initialiser even if the type has a :D smiley, and a :D type without an
initialiser should imply 'is required'.

The first and second examples below should be equivalent.

    > class { has Int:D $.count }.new(count => 42)
    ===SORRY!=== Error while compiling <unknown file>
    Variable definition of type Int:D requires an initializer
    at <unknown file>:1

    > class { has Int:D $.count is required = Int }.new(count => 42)
    <anon>.new(count => 42)


And the error message should probably be this:

    > class { has Int $.count is required }.new()
    The attribute '$!count' is required, but you did not provide a value for it.
      in block <unit> at <unknown file>:1

Rather than this:

    > class { has Int:D $.count is required = Int }.new()
    Type check failed in assignment to $!count; expected Int:D but got Int
      in block <unit> at <unknown file>:1


-- 
"I use RMS as a guide in the same way that a boat captain would use
 a lighthouse.  It's good to know where it is, but you generally
 don't want to find yourself in the same spot." - Tollef Fog Heen

Reply via email to