Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi dispatch error on signature with coerce and smiley #6156

Open
p6rt opened this issue Mar 17, 2017 · 3 comments
Open

multi dispatch error on signature with coerce and smiley #6156

p6rt opened this issue Mar 17, 2017 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 17, 2017

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

Searchable as RT131014$

@p6rt
Copy link
Author

p6rt commented Mar 17, 2017

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 <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)

@p6rt
Copy link
Author

p6rt commented Sep 8, 2017

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 <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

@p6rt
Copy link
Author

p6rt commented Sep 8, 2017

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

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant