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


The first eval complains that I can't use a coercer on a variable... However, 
the latter ones fail to detect use of coercion and don't complain, but don't 
coerce either.

18:43   Zoffix  m: class { has Int() $.x = '42'}.new.x
18:43   camelia         rakudo-moar fb7dd8: OUTPUT: «5===SORRY!5=== Error while 
compiling <tmp>␤Coercion Int(Any) is insufficiently type-like to qualify a 
variable␤at <tmp>:1␤------> 3class { has Int() $.x7⏏5 = '42'}.new.x␤    
expecting any of:␤        constraint␤»

18:43   Zoffix  m: class { has Int:D() $.x = '42'}.new.x
18:43   camelia         rakudo-moar fb7dd8: OUTPUT: «Type check failed in 
assignment to $!x; expected Int:D but got Str ("42")␤  in block <unit> at <tmp> 
line 1␤␤»
18:45   Zoffix  m: class { has Int:D() $.x = 42}.new(:x('42'))
18:45   camelia         rakudo-moar fb7dd8: OUTPUT: «Type check failed in 
assignment to $!x; expected Int:D but got Str ("42")␤  in block <unit> at <tmp> 
line 1␤␤»

Reply via email to