On Fri, 17 Mar 2017 13:12:19 -0700, fernandocor...@gmail.com wrote: > https://irclog.perlgeek.de/perl6/2017-03-17#i_14283289 > > 19:03 <https://irclog.perlgeek.de/perl6/2017-03-17#i_14283289> > SmokeMachine m: > class C {proto method xxx(|) {*}; multi method xxx(Str(Cool:D) $n) > {1}; > multi method xxx(Str(Cool:D) $n, Int:D $p) {2}}; say C.new.xxx("42") # > <- > is that expected? > 19:03 <https://irclog.perlgeek.de/perl6/2017-03-17#i_14283290> camelia > rakudo-moar > 79f268: OUTPUT: «Ambiguous call to 'xxx'; these signatures all > match::(C > $: Cool:D $n, *%_):(C $: Cool:D $n, *%_) in block <unit> at <tmp> > line > 1» > > 19:18 <https://irclog.perlgeek.de/perl6/2017-03-17#i_14283339> IOninja > m: > class C {multi method xxx(Str(Cool:D) $z) {1}; }.new.xxx: 'z' > 19:18 <https://irclog.perlgeek.de/perl6/2017-03-17#i_14283340> camelia > rakudo-moar > 79f268: OUTPUT: «Ambiguous call to 'xxx'; these signatures all > match::(C > $: Cool:D $z, *%_):(C $: Cool:D $z, *%_) in block <unit> at <tmp> > line > 1» > > Just another Perl Hacker, > Fernando (SmokeMachine)
Note this only happens when the parameter matches both of the component types in the coercion type. This is a combination of bugs. First: perl6 -e 'multi sub a (Str(Str) $a) { $a.say }; a("42")' Ambiguous call to 'a'; these signatures all match: :(Str $a) :(Str $a) in block <unit> at -e line 1 ...in the binder, for some reason, when the sorting graph is built, an extra candidate is added for coercive types. So if you have: multi sub a(Str(Int), Rat(Num) {...}; ... the graph will also contain multi sub a(Int, Num) { } ... though it will not contain: multi sub a(Str(Int), Num) { } or multi sub a(Int, Rat(Num)) { } ... which might(?) be a source of other problems not mentioned in this ticket. Or maybe not... it might be fine for sorting purposes. Will ponder. Anyway, all this has nothing to do with smileys, but it is why you see multiple candidates in the error output. Why the problem only manifests with a smiley needs sussing. I have not looked into it deeply enough to say for sure yet, but I'm guessing that the smileys come in when narrowness is assessed... smileys do not seem to be explicitly used in the narrowness comparator used during sorting, though that may be due to a move towards making them real types mitigating the need to do so. Perhaps relevant-- note this: $ perl6 -e 'use nqp; say nqp::istype(Cool:D, Cool:D);' 0