Skip Menu |
Report information
Id: 130364
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: TimTom <tim.bollman [at]>

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)

Subject: [BUG] Cannot use type parameter to constrain return value
From: Tim Bollman <Tim.Bollman [...]>
Date: Fri, 16 Dec 2016 22:15:26 +0000
To: "rakudobug [...]" <rakudobug [...]>
Download (untitled) / with headers
text/plain 633b

You cannot use the type provided in a parametric role to constrain the return value of a method. It errors with "X::TypeCheck::Return exception produced no message".

use v6;
use Test;

role A[::B] {
    method build-it(*@attr) {
    method build-it-constrain(*@attr) returns B {

class Point {
    has $.x;
    has $.y;

plan 2;

lives-ok {
    my Point $p = A[Point] => 5, y => 10);
}, 'Built without constraint';

lives-ok {
    my Point $p = A[Point] => 5, y => 10);
}, 'Built with constraint';

This service is sponsored and maintained by Best Practical Solutions and runs on infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at