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


This bug is for rakudo version 2015.11-283-g0ede335 built on MoarVM
version 2015.11-21-g469ba64 implementing Perl v6.b.

Take the following code:

    subset Empty of Str where /^$/;

    say "assignment:";
    try my Empty $x = "a";
    say $!.message;
    say $!.^name;

    say "binding:";
    sub f(Empty $) {}
    try f("a");
    say $!.message;
    say $!.^name;

This outputs:

    assignment:
    Type check failed in assignment to $x; expected Empty but got Str
    X::TypeCheck::Assignment
    binding:
    Constraint type check failed for parameter '<anon>'
    X::AdHoc

The X::AdHoc is wrong I think, it should be a X::TypeCheck::Binding,
analogous to the assignment.

Using a non-subset type also works correctly, if you can get it through
the compiler saying it'll never work:

    sub g(Str $) {}
    try g(False ?? "" !! 1); # thwart compiler
    say $!.message;
    say $!.^name;

Outputs:

    Type check failed in binding <anon>; expected Str but got Int
    X::TypeCheck::Binding

Reply via email to