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 allows declaration of a multi and an only sub in the same scope, even in the absence of a 'proto' declaration #965

Closed
p6rt opened this issue May 2, 2009 · 5 comments

Comments

@p6rt
Copy link

p6rt commented May 2, 2009

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

Searchable as RT65322$

@p6rt
Copy link
Author

p6rt commented May 2, 2009

From @masak

<masak> rakudo​: multi sub foo(Int $n where 1) { say "OH HAI" }; sub
foo(Int $n) { say "CHEEZBURGER" }; foo(1)
<p6eval> rakudo ec69e2​: OUTPUT«CHEEZBURGER␤»
<masak> anyone know if that's in RT already?
<jnthn> That should be an error unless there is a proto in scope.
<masak> right.
<jnthn> (which in this case there wasn't)
<jnthn> rakudo​: proto foo() { }; sub foo(Int $x) { 1 }; sub foo(Str
$x) { 2 }; say foo(1); say foo("a");
<p6eval> rakudo ec69e2​: OUTPUT«1␤2␤»
<jnthn> Anyway, it works.
<masak> jnthn​: aye, but the CHEEZBURGER one shouldn't work.
<jnthn> aye, we should complain loudly about that one.

@p6rt
Copy link
Author

p6rt commented Oct 10, 2009

From @kyleha

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

commit 13637aaf15a83ef65dfdfc9b3e12f04ec37b2ea0
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Sat Oct 10 23​:45​:49 2009 +0000

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

Inline Patch
diff --git a/t/spec/S06-multi/proto.t b/t/spec/S06-multi/proto.t
index 6e78b4f..b1e4ecf 100644
--- a/t/spec/S06-multi/proto.t
+++ b/t/spec/S06-multi/proto.t
@@ -1,6 +1,6 @@
 use v6;
 use Test;
-plan 13;
+plan *;
 
 # Test for proto definitions
 class A { }
@@ -54,4 +54,16 @@ is(foo(42),    1, 'dispatch with no possible candidates fell back to proto');
 eval_dies_ok 'proto rt68242($a){};proto rt68242($c,$d){};',
     'attempt to define two proto subs with the same name dies';
 
+# RT #65322
+{
+    my $rt65322 = q[
+        multi sub rt65322( Int $n where 1 ) { 1 }
+              sub rt65322( Int $n ) { 2 }
+    ];
+    #?rakudo todo 'RT #65322'
+    eval_dies_ok $rt65322, "Can't define sub and multi sub without proto";
+}
+
+done_testing;
+
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented Oct 10, 2009

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

@p6rt
Copy link
Author

p6rt commented Feb 16, 2010

From @jnthn

On Sat Oct 10 16​:50​:45 2009, KyleHa wrote​:

diff --git a/t/spec/S06-multi/proto.t b/t/spec/S06-multi/proto.t
index 6e78b4f..b1e4ecf 100644
--- a/t/spec/S06-multi/proto.t
+++ b/t/spec/S06-multi/proto.t
@​@​ -54,4 +54,16 @​@​ is(foo(42), 1, 'dispatch with no possible
candidates fell back to proto');
eval_dies_ok 'proto rt68242($a){};proto rt68242($c,$d){};',
'attempt to define two proto subs with the same name dies';

+# RT #​65322
+{
+ my $rt65322 = q[
+ multi sub rt65322( Int $n where 1 ) { 1 }
+ sub rt65322( Int $n ) { 2 }
+ ];
+ #?rakudo todo 'RT #​65322'
+ eval_dies_ok $rt65322, "Can't define sub and multi sub without
proto";
+}
+

Just un-todo'd this test, since it's now passing. Resolving ticket.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Feb 16, 2010

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

@p6rt p6rt closed this as completed Feb 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