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

return value of multi declaration should be just one candidate. #1766

Closed
p6rt opened this issue May 17, 2010 · 5 comments
Closed

return value of multi declaration should be just one candidate. #1766

p6rt opened this issue May 17, 2010 · 5 comments

Comments

@p6rt
Copy link

p6rt commented May 17, 2010

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

Searchable as RT75136$

@p6rt
Copy link
Author

p6rt commented May 17, 2010

From lewis@wall.org

When I run​:

multi x (Int $x) {...}
(multi x (Str $x) {...})>>.candidates>>.say

It outputs​:
x
x

(note there are two x's). The declaration of the second multi is returning
the multisub with both candidates, rather than just the sub in the ()s.
According to TimToady, the latter is the correct behavior, and not the
former.

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

From @jnthn

On Sun May 16 21​:11​:42 2010, lewis@​wall.org wrote​:

When I run​:

multi x (Int $x) {...}
(multi x (Str $x) {...})>>.candidates>>.say

It outputs​:
x
x

(note there are two x's). The declaration of the second multi is
returning
the multisub with both candidates, rather than just the sub in the ()s.
According to TimToady, the latter is the correct behavior, and not the
former.

This was fixed recently (by pmichaud++ I believe) and it now outputs
just the one x. Given to moritz++ for spectesting.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

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

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

From @kyleha

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

commit 17f12a34c378a536e8e9a816a149785bfd2bb5b6
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Fri Jul 16 08​:07​:21 2010 +0000

  [t/spec] tests for RT #​75136​: declaring a multi just returns the current candidate, not the whole set
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;31720 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S06-multi/syntax.t b/t/spec/S06-multi/syntax.t
index fd21d07..6f9a55e 100644
--- a/t/spec/S06-multi/syntax.t
+++ b/t/spec/S06-multi/syntax.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 34;
+plan *;
 
 # L<S06/Routine modifiers/>
 # L<S06/Parameters and arguments/>
@@ -114,6 +114,20 @@ ok(~&foo ~~ /foo/,  'a multi stringifies sensibly');
     is 21.$m(), 42, 'can write anonymous methods inside multi subs';
 }
 
+
+# RT #75136
+# a multi declaration should only return the current candidate, not the whole
+# set of candidates.
+{
+    multi sub koala(Int $x) { 42 * $x };
+
+    my $x = multi sub koala(Str $x) { 42 ~ $x }
+    is $x.candidates.elems,
+        1, 'multi sub declaration returns just the current candidate';
+    is $x('moep'), '42moep', 'and that candidate works';
+    dies_ok { $x(23) }, '... and does not contain the full multiness';
+}
+
 done_testing;
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Jul 16, 2010

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

@p6rt p6rt closed this as completed Jul 16, 2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant