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

The type binder breaks together for anonymous parameters (and parameters with the same name) with different constraints in Rakudo #1363

Closed
p6rt opened this issue Oct 15, 2009 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 15, 2009

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

Searchable as RT69798$

@p6rt
Copy link
Author

p6rt commented Oct 15, 2009

From @masak

<masak> hooray for runnable, concrete examples!
<PerlJam> indeed, moritz_++
<moritz_> don't praise me until you actually tested it :-)
<PerlJam> my rakudo barfs on it, but that's my rakudo's fault
<PerlJam> (perhaps rakudo in general)
<moritz_> yes, I just tested it
<moritz_> and I don't understand why
<moritz_> we have that as a test case even
<PerlJam> with anonymous scalars?
<moritz_> don't think so
* PerlJam bets not
<PerlJam> yeah, if I give the scalars names it works fine
<PerlJam> if I give *one* of the scalars a name, it works fine
* masak submits rakudobug
<moritz_> masak​: you are being called to du... d'oh, I'm too slow
<masak> hah!
<masak> here's a minimal example​:
<masak> rakudo​: class Scissors {}; class Paper {}; multi wins(Scissors
$, Paper $) {}; multi wins($, $) {}; wins(Scissors, Paper)
<p6eval> rakudo d5a2ee​: OUTPUT«Parameter type check failed; expected
Scissors, but got Paper for $ in call to wins [...]
<masak> rakudo​: class Scissors {}; class Paper {}; multi wins(Scissors
$a, Paper $a) {}; multi wins($, $) {}; wins(Scissors, Paper)
<p6eval> rakudo d5a2ee​: OUTPUT«Parameter type check failed; expected
Scissors, but got Paper for $a in call to wins [...]
<masak> std​: sub foo($a, $a) {}
<p6eval> std 28796​: OUTPUT«Potential difficulties​:␤ Useless
redeclaration of variabl [...] ok 00​:02 105m␤»
<masak> so it's a warning, not an error?
<masak> then the binder must know what to do when a call to such a
routine actually happens.

@p6rt
Copy link
Author

p6rt commented Oct 15, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S06-multi/type-based.t

commit fff5be9d99e2e6824395bb2183062e57c746336c
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Thu Oct 15 17​:19​:52 2009 +0000

  [t/spec] tests for RT #​69798
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;28798 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S06-multi/type-based.t b/t/spec/S06-multi/type-based.t
index 0027d4d..251a90c 100644
--- a/t/spec/S06-multi/type-based.t
+++ b/t/spec/S06-multi/type-based.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 45;
+plan *;
 
 # type based dispatching
 #
@@ -83,8 +83,22 @@ is(mmd(1..3), 2, 'Slurpy MMD to listop via list');
     is wins(Scissor.new, Paper.new),   1,  'Basic sanity 2';
     is wins(Paper.new,   Paper.new),   0,  'multi dispatch with faked generics';
     is wins(Paper.new,   Scissor.new), -1, 'fallback if there is a faked generic';
+
+    # now try again with anonymous parameters (see RT #69798)
+    multi wins_anon(Scissor $, Paper   $) { 1  }
+    multi wins_anon(Paper   $, Stone   $) { 1  }
+    multi wins_anon(Stone   $, Scissor $) { 1  }
+    multi wins_anon(::T     $, T       $) { 0  }
+    multi wins_anon(        $,         $) { -1 }
+
+    #?rakudo 3 skip 'RT 69798'
+    is wins_anon(Scissor, Paper),  1, 'MMD with anonymous parameters (1)';
+    is wins_anon(Paper,   Paper),  0, 'MMD with anonymous parameters (2)';
+    is wins_anon(Stone,   Paper), -1, 'MMD with anonymous parameters (3)';
+
 }
 
+
 {
     multi m($x,$y where { $x==$y }) { 0 };
     multi m($x,$y) { 1 };
@@ -164,4 +178,6 @@ is(mmd(1..3), 2, 'Slurpy MMD to listop via list');
     is y(1, 2.5), 2, 'generics in multis (-)';
 }
 
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 15, 2009

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

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

From @moritz

Fixed with the new signature binder, tests unfudged

@p6rt
Copy link
Author

p6rt commented Oct 20, 2009

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

@p6rt p6rt closed this as completed Oct 20, 2009
@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