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


$ perl6 -e 'my Int $a is default("foo");'
===SORRY!=== Error while compiling -e
Default value 'foo' will never bind to a parameter of type Int
at -e:1
------> my Int $a is default("foo")⏏;
    expecting any of:
        constraint
$ perl6 -e 'class A { has Int $.a is default("foo"); }'
===SORRY!=== Error while compiling -e
Type check failed in assignment to $!a; expected Int but got Str ("foo")
at -e:1

An attribute should probably throw X::Parameter::Default::TypeCheck, like the
simple variable does, rather than X::TypeCheck::Assignment+{X::Comp}

I'll be adding fudged tests to S02-names/is_default for this.

Reply via email to