Re: cannot create an instance of subset type

2020-07-11 Thread Ben Davies
It looks like you're trying to create an alias for a type. I'd use a constant for this, not a subset, for reasons Brad has already explained. Your code runs fine for me when DEF is written like my constant DEF = ABC.

Re: cannot create an instance of subset type

2020-07-11 Thread Elizabeth Mattijsen
> On 10 Jul 2020, at 23:37, Brad Gilbert wrote: > I honestly think that there is an argument to be made that it shouldn't even > be possible to write a `subset` without a `where` clause. Making the "where" clause non-optional, is remarkably simple: removing a '?' However, there appear to be qui

Re: cannot create an instance of subset type

2020-07-11 Thread Marcel Timmerman
On 2020-07-10 23:37, Brad Gilbert wrote: Subset types are not object types. A subset is basically a bit of checking code and base type associated with a new type name. In something like:     my ABC $a .= new; That is exactly the same as:     my ABC $a = ABC.new; Well there is no functiona

Re: cannot create an instance of subset type

2020-07-10 Thread Brad Gilbert
Subset types are not object types. A subset is basically a bit of checking code and base type associated with a new type name. In something like: my ABC $a .= new; That is exactly the same as: my ABC $a = ABC.new; Well there is no functional `.new` method on any subset types, so `DEF.

cannot create an instance of subset type

2020-07-10 Thread Marcel Timmerman
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 inst