Tests:
https://github.com/perl6/roast/commit/fa9a6b05f665bef3b5b45cb35d4018b2a8368c31

On Mon, Jul 25, 2016 at 8:19 AM Brian S. Julin via RT <
perl6-bugs-follo...@perl.org> wrote:

> On Fri Jul 22 15:34:49 2016, b...@abrij.org wrote:
> >
> > rakudo PR #829 should fix this on moarvm.  JVM and JS fixes may also
> > be needed.
>
>
> I added some error awesomeization to that PR so that now:
>
> $ perl6 -e 'my Int:D @a; @a[0] = Nil; @a.say;'
> Type check failed in assignment to @a; expected type Int:D cannot be
> itself (perhaps Nil was assigned to a :D which had no default?)
>   in block <unit> at -e line 1
>
> $ perl6 -e 'my Int:D @a; @a[0] = Int:D; @a.say;'
> Type check failed in assignment to @a; expected type Int:D cannot be
> itself (perhaps Nil was assigned to a :D which had no default?)
>   in block <unit> at -e line 1
>
> $ perl6 -e 'my Int:D $a = 42; $a := Nil; $a.say;'
> Type check failed in binding; expected Int:D but got Nil (Nil)
>   in block <unit> at -e line 1
>
> $ perl6 -e 'my Int:D $a = 42; $a := Int:D; $a.say;'
> Type check failed in binding; expected type Int:D cannot be itself
>   in block <unit> at -e line 1
>
> And though there is an awesomeization for sub return types it does not
> work,
> because the X is being fed the raw type not the smilied typed.
>
> $ perl6 -e '{ sub f() of Str:D { Str:D }; f(); CATCH {
> $_.expected.WHAT.say }}'
> (Str)
> Type check failed for return value; expected Str but got Str:D (Str:D)
>   in sub f at -e line 1
>   in block <unit> at -e line 1
>
> ...that is a separate issue so, not touching it.
>
> Another thing I'm not touching is this:
>
> $ perl6 -e 'my Int:D %a; %a<a> := Str; %a.say;'
> {a => (Str)}
>
> ...note how the array version fails (correctly) in the binder:
>
> $ perl6 -e 'my Int:D @a; @a[0] := Str; @a.say;'
> Cannot resolve caller BIND-POS(Array[Int:D]: Int, Str); none of these
> signatures match:
>     (Array:D $: Int $pos, Int:D \bindval, *%_)
>     (Array:D $: int $pos, Int:D \bindval, *%_)
>   in block <unit> at -e line 1
> $ perl6 -e 'my Int:D @a;
> @a.^find_method("BIND-POS").candidates».signature.say'
> ((Array:D $: Int $pos, Int:D \bindval, *%_) (Array:D $: int $pos, Int:D
> \bindval, *%_))
> $ perl6 -e 'my Int:D %a;
> %a.^find_method("BIND-KEY").candidates».signature.say'
> ((Hash:D $: \key, Mu \bindval, *%_))
>
> ...and note in Hash.pm there are comments on the hash class BIND-KEY
> method saying
> it should be a multi, but that blows up setting compilation -- I verified
> this is still
> currently the case.  That might be related.
>
> One thing the awesomeized errors do not get right is this, but it is in a
> half broken,
> half NYI state anyway:
>
> $ perl6 -e 'role A[::T $t] { has T:D $.f = 1; }; A[Int].new'
> X::TypeCheck::Assignment exception produced no message
>   in any  at gen/moar/m-Metamodel.nqp line 1736
>   in block <unit> at -e line 1
>
> (versus current behavior, also wrong as it should not fail, if ever
> implemented):
>
> (03:31:08 PM) skids: m: role A[::T $t] { has T:D $.f = 1; }; A[Int].new
> (03:31:09 PM) camelia: rakudo-moar 478671: OUTPUT«Type check failed in
> assignment to $!f; expected T:D but got Int (1)␤  in any  at
> gen/moar/m-Metamodel.nqp line 1736␤  in block <unit> at <tmp> line 1␤␤»
>
> Evidence that it should not be hoped to work:
>
> $ perl6 -e 'role A[::T $t] { method f { (T:D).perl.say } }; A[Int].new.f()'
> ===SORRY!=== Error while compiling -e
> Type too complex to form a definite type
> at -e:1
>
>
>

Reply via email to