Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

multi dispatch error on signature with coerce and smiley #6156

Open p6rt opened 7 years ago

p6rt commented 7 years ago

Migrated from rt.perl.org#131014 (status was 'open')

Searchable as RT131014$

p6rt commented 7 years ago

From @FCO

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 \ at \ 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 \ at \ line 1␤␤»

Just another Perl Hacker, Fernando (SmokeMachine)

p6rt commented 7 years ago

From @skids

On Fri, 17 Mar 2017 13​:12​:19 -0700, fernandocorrea@​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 \ at \ 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 \ at \ 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 \ 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

p6rt commented 7 years ago

The RT System itself - Status changed from 'new' to 'open'