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

rakudo does not disambiguate on nominal types in subsignatures #2181

Closed
p6rt opened this issue Sep 20, 2010 · 6 comments
Closed

rakudo does not disambiguate on nominal types in subsignatures #2181

p6rt opened this issue Sep 20, 2010 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Sep 20, 2010

Migrated from rt.perl.org#77950 (status was 'resolved')

Searchable as RT77950$

@p6rt
Copy link
Author

p6rt commented Sep 20, 2010

From @moritz

15​:33 < jnthn> rakudo​: multi f ($ (Int :$value)) { say "Int $value" };
multi f($ (Str :$value)) { say "Str $value" }; f('a' => 3); f('a' => 'foo')
15​:33 <+p6eval> rakudo 523da4​: OUTPUT«Ambiguous dispatch to multi 'f'.
Ambiguous candidates had signatures​:␤​:(Any (Int :value($value)))␤​:(Any
  (Str :value($value)))␤␤ in main program body at line 22​:/tmp/6gqT8mG2KW␤»

...
15​:34 < jnthn> moritz_​: Yeah...even then, I'm a tad surprised about the
ambiguity though.
15​:35 < jnthn> I'm not sure I understand why it's calling it out as
ambiguous.
15​:35 < jnthn> That's worth of investigation.
15​:35 < moritz_> and worth a ticket :-)
15​:35 < jnthn> Sure, otherwise I'll forget. :-)

@p6rt
Copy link
Author

p6rt commented Sep 20, 2010

From @moritz

15​:49 < jnthn> It may not be a bug.
15​:49 < jnthn> rakudo​: multi f ($ (Int :$value!)) { say "Int $value" };
multi
  f( $ (Str :$value!)) { say "Str $value" }; f('a' => 3);
f('a' =>
  'foo')
15​:49 <+p6eval> rakudo 523da4​: OUTPUT«No applicable candidates found to
  dispatch to for 'f'. Available candidates are​:␤​:(Any (Int
  :value($value)!))␤​:(Any (Str :value($value)!))␤␤ in main
  program body at line 22​:/tmp/DBB23kVew9␤»
15​:50 < jnthn> OK, that looks more like one...
15​:50 < jnthn> Thing is that it *can* match both signatures maybe if the
  parameter is optional
15​:50 < jnthn> OTOH it should still fail the type check
15​:50 < jnthn> So, hm
15​:50 * moritz_ adds that to the ticket
15​:50 < jnthn> rakudo​: ('a' => 3).Capture.perl
15​:50 <+p6eval> rakudo 523da4​: ( no output )
15​:50 < jnthn> rakudo​: ('a' => 3).Capture.perl.say
15​:50 <+p6eval> rakudo 523da4​: OUTPUT«\()␤»
15​:50 < jnthn> Oh.
15​:51 < jnthn> rakudo​: (1/2).Capture.perl.say
15​:51 <+p6eval> rakudo 523da4​: OUTPUT«\("numerator" => 1, "denominator"
=> 2)␤»
15​:51 < jnthn> OK, pair capture coercion is FAIL

@p6rt
Copy link
Author

p6rt commented Sep 20, 2010

@moritz - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Oct 20, 2011

From @coke

On Mon Sep 20 06​:51​:49 2010, moritz wrote​:

15​:49 < jnthn> It may not be a bug.
15​:49 < jnthn> rakudo​: multi f ($ (Int :$value!)) { say "Int $value" };
multi
f( $ (Str :$value!)) { say "Str $value" }; f('a' => 3);
f('a' =>
'foo')
15​:49 <+p6eval> rakudo 523da4​: OUTPUT«No applicable candidates found to
dispatch to for 'f'. Available candidates are​:␤​:(Any (Int
:value($value)!))␤​:(Any (Str :value($value)!))␤␤ in main
program body at line 22​:/tmp/DBB23kVew9␤»
15​:50 < jnthn> OK, that looks more like one...
15​:50 < jnthn> Thing is that it *can* match both signatures maybe if the
parameter is optional
15​:50 < jnthn> OTOH it should still fail the type check
15​:50 < jnthn> So, hm
15​:50 * moritz_ adds that to the ticket
15​:50 < jnthn> rakudo​: ('a' => 3).Capture.perl
15​:50 <+p6eval> rakudo 523da4​: ( no output )
15​:50 < jnthn> rakudo​: ('a' => 3).Capture.perl.say
15​:50 <+p6eval> rakudo 523da4​: OUTPUT«\()␤»
15​:50 < jnthn> Oh.
15​:51 < jnthn> rakudo​: (1/2).Capture.perl.say
15​:51 <+p6eval> rakudo 523da4​: OUTPUT«\("numerator" => 1, "denominator"
=> 2)␤»
15​:51 < jnthn> OK, pair capture coercion is FAIL

Recent IRC chat led to​:

10​:33 < jnthn> nom​: multi f ((Int :$value, *%)) { say "Int $value" }; multi
  f((Str :$value, *%)) { say "Str $value" }; f('a' => 3); f('a' =>
  'foo')
10​:33 <+p6eval> nom e17c13​: OUTPUT«Int 3␤Str foo␤»
10​:33 < jnthn> [Coke]​: The code in the ticket would need to be the above to
  work; note the extra *%
10​:34 < [Coke]> jnthn​: so, given that, we can reject the ticket? ;)
10​:35 < jnthn> [Coke]​: I'd consider it fixed
10​:35 < [Coke]> jnthn​: needs test, you think?
10​:35 < jnthn> [Coke]​: It gave the wrong error before, now it gives the right
  one
10​:36 < jnthn> [Coke]​: I can blieve we need a test for the correct version of
  it.

So, Closable with tests.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Oct 20, 2011

From @moritz

Tests in S06-signature/unpack-object.t.

@p6rt
Copy link
Author

p6rt commented Oct 20, 2011

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Oct 20, 2011
@p6rt p6rt added the testneeded label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant