Cannot use example about roles from official doc in Raku

Viewed 60

Following this defenitions from docs.raku, I get the following error with rakudo 2022.03

platform-pro (pro) in ~ via ⬢ v12.4.0
❯ raku                                                                                                           ~
Welcome to Rakudo™ v2022.03.
Implementing the Raku® Programming Language v6.d.
Built on MoarVM version 2022.03.

To exit type 'exit' or '^D'
>  role Canine {
*  method bark { ... }
*  }
(Canine)
>  class Dog does Canine {
*  method bark { say  "Woof" }
*  }
===SORRY!=== Error while compiling:
Package 'Dog' already has a method 'bark' (did you mean to declare a multi method?)
at line 2

I changed the method to multi but:

>  role Canine {
*  method bark { ... }
*  }
(Canine)
>  class Dog does Canine {
*  multi method bark { say  "Woof" }
*  }
===SORRY!=== Error while compiling:
No appropriate parametric role variant available for 'Canine':
    Ambiguous call to '(Dog)'; these signatures all match:
      (::$?CLASS ::::?CLASS Mu $)
      (::$?CLASS ::::?CLASS Mu $)

Thanks to the comments it seems a problem in the REPL:

role Canine {
    method bark { say  "Woof" };
}

class Dog does Canine {
    method bark { say  "Woof" };
}

my $d = Dog.new();

$d.bark

if save this to a file and execute

☸ platform-pro (pro) in learn/raku/stackoverflow via  v3.9.10 (python-3.9.10) via  v6.d v2022.03
❯ raku prueba-roles.raku                                                                ~/learn/raku/stackoverflow
Woof
0 Answers
Related