develooper Front page | perl.perl6.users | Postings from July 2020

cannot create an instance of subset type

Thread Next
From:
Marcel Timmerman
Date:
July 10, 2020 20:18
Subject:
cannot create an instance of subset type
Message ID:
c0a48634-65be-72b3-1c4a-71a9082e74bf@gmail.com
Hi,

Using the next code I get an error on the instantiation of $d2;

---
use v6;

class ABC {
   method s ( Int $i ) { say $i + 10; }
}

subset DEF of ABC;

my ABC $a .= new;
$a.s(10);   # 20

my DEF $d1 = $a;
$d1.s(11);  # 21

my DEF $d2 .= new;
$d2.s(12);
---

Error is

You cannot create an instance of this type (DEF)
   in block <unit> at xt/subset-test.pl6 line 15

Why is this?

Regards,
Marcel

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About