Jonathan (>), Carl (>>): > > This might be in RT already, but I didn't find it, so... > > > > <ihrd> rakudo: multi foo (@a) { 1 }; multi foo ($a, %h?) { 2 }; say > > foo(<1 2 3>); > > <p6eval> rakudo 69b318: OUTPUT«Ambiguous dispatch to multi 'foo'. > > Ambiguous candidates had signatures::(Positional.new() @a):(Any $a, > > Associative.new() %h?) [...] > > * masak submits rakudobug > > > > As for arity, both methods can match. But the first candidate has a > > type constraint Positional on its first parameter, so it should be > > narrower than the second one, which doesn't. > It's not so clear cut that this is a bug. Positional is a role, and is > done by some things (like List, Array, etc), but doesn't have a > relationship with Any in any way. The default parameter type is Any. > Thus if you try Positional ~~ Any, you'll get false (and vice versa - > they are tied types so far as the dispatcher is concerned). > > Anyway, the dispatcher is behaving as I would have expected in terms of > considering those candidates tied. I do agree it isn't very dwim-y, but > nothing occurs to me right away that we could do in order to make it > dwim more...
I see. In short, there's a tie because Positional isn't narrower than Any. I get it now, and agree on a formal level. ...the problem is just that the sigils '@' and '%' _feel_ like they should be narrower than '$', because the latter can contain anything. The question is probably whether it's possible to reflect that intuition in the MMDer without breaking something important.