On Sat, 03 Jun 2017 06:24:02 -0700, cookbook_...@yahoo.co.jp wrote:
> See the following codes and results:
> 
> $ perl6 -e 'class A { multi method f(:$vert!, Code :&c = {;}){}; multi
> method f(:$func!, Code :&c = {;}){}; }; my $a = A.new;
> $a.f(:func(10));'
> Cannot resolve caller f(A: :func(Int)); none of these signatures
> match:
>     (A $: :$vert!, Code :&c = { ... }, *%_)
>     (A $: :$func!, Code :&c = { ... }, *%_)
>   in block <unit> at -e line 1
> 
> 
> $ perl6 -e 'class A { multi method f(:$vert!, :&c = {;}){}; multi
> method f(:$func!, :&c = {;}){
> }; }; my $a = A.new; $a.f(:func(10));' # works
> 
> 
> I think the 1st example should work same as the 2nd example.
> 
> 
> $ perl6 --version
> This is Rakudo version 2017.05-315-g160de7e built on MoarVM version
> 2017.05-25-g62bc54e
> implementing Perl 6.c.


Thank you for the report. However, this is not a bug.

The `&` sigil already carries a meaning that the parameter is type-constrained 
to Callable type.

`Code :&c` means `:$c` parameter expects a Callable[Code] type; a `Callable`, 
parameterized with `Code`.

The same, for example, applies with `Int :@stuff`. The `Int` is a 
parametarization of the Positional role,
and the parameter expects a `Positional[Int]` argument.

Your second version is correct. Just remove `Code`. If you insist on `Code` 
type, then remove the `&` sigil and use the `$` sigil

Reply via email to