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 doesn't recognize when subs or methods are being redefined #226

Closed
p6rt opened this issue Aug 11, 2008 · 13 comments
Closed

rakudo doesn't recognize when subs or methods are being redefined #226

p6rt opened this issue Aug 11, 2008 · 13 comments

Comments

@p6rt
Copy link

p6rt commented Aug 11, 2008

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

Searchable as RT57788$

@p6rt
Copy link
Author

p6rt commented Aug 11, 2008

From @masak

r30166​:
$ ./perl6 -e 'sub x{};sub x{1};say x'
1
$ ./perl6 -e 'class A{method x{1};method x{}};say A.new.x'
1

I think it's reasonable to expect both of these to give at least a
warning, as Perl 5 does.

$ perl -we 'sub x {} sub x {}'
Subroutine x redefined at -e line 1.

@p6rt
Copy link
Author

p6rt commented Dec 12, 2008

From @masak

<peters> rakudo​: sub foo { }; sub foo {}; say "ok";
<polyglotbot> OUTPUT[ok�]
<masak> peters​: nice one. that's a bug.
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented May 8, 2009

From @jnthn

On Fri Dec 12 13​:54​:14 2008, masak wrote​:

<peters> rakudo​: sub foo { }; sub foo {}; say "ok";
<polyglotbot> OUTPUT[ok�]
<masak> peters​: nice one. that's a bug.
* masak submits rakudobug

It warns now. Can't close this ticket since we don't do anything for
re-defined methods just yet, and that ticket got merged into this one.
But at least the above gives a warning...

Jonathan

@p6rt
Copy link
Author

p6rt commented May 8, 2009

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

@p6rt
Copy link
Author

p6rt commented May 8, 2009

From @pmichaud

On Fri, May 08, 2009 at 04​:20​:28AM -0700, jnthn@​jnthn.net via RT wrote​:

On Fri Dec 12 13​:54​:14 2008, masak wrote​:

<peters> rakudo​: sub foo { }; sub foo {}; say "ok";
<polyglotbot> OUTPUT[ok�]
<masak> peters​: nice one. that's a bug.
* masak submits rakudobug

It warns now. Can't close this ticket since we don't do anything for
re-defined methods just yet, and that ticket got merged into this one.
But at least the above gives a warning...

Maybe we can split the tickets again, or we can close this ticket and
open a new one specific to re-defined methods.

Pm

@p6rt
Copy link
Author

p6rt commented Jul 8, 2009

From @kyleha

The method redefinition problem (which is still open) looks the same as
RT #​67024, which is tested in S12-methods/multi.t. The problem of
redefining a regular subroutine appears to be tested in
S06-advanced_subroutine_features/stub.t.

@p6rt
Copy link
Author

p6rt commented Aug 7, 2009

From vetinari@ankh-morp.org

$ cat test.p6
use v6;
class A { sub a { say "a" }; sub a { say "a" } }
grammar B { token b { 'b' }; token b { 'b' } };
class C { method c { say "c" }; method c { say "c" } }
### vim​: ft=perl6 ts=4 sw=4 expandtab
$ ./perl6 test.p6
Redefinition of routine a
$

@p6rt
Copy link
Author

p6rt commented Aug 12, 2009

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S10-packages/basic.t

commit 14bcd61d38e8e0df7bdb18a0ce9d9ed539b23837
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Wed Aug 12 01​:06​:05 2009 +0000

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

Inline Patch
diff --git a/t/spec/S10-packages/basic.t b/t/spec/S10-packages/basic.t
index 15c6d21..07eaa19 100644
--- a/t/spec/S10-packages/basic.t
+++ b/t/spec/S10-packages/basic.t
@@ -4,7 +4,7 @@ use v6;
 
 use Test;
 
-plan 42;
+plan 47;
 
 regex fairly_conclusive_platform_error {:i ^\N*<<Null?>>}
 
@@ -174,6 +174,21 @@ eval_lives_ok q' module MapTester { (1, 2, 3).map: { $_ } } ',
        'array initialization works fine in imported subs';
 }
 
+# RT #68290
+{
+    eval_dies_ok q[class A { sub a { say "a" }; sub a { say "a" } }],
+                 'sub redefined in class dies';
+    eval_dies_ok q[package P { sub p { say "p" }; sub p { say "p" } }],
+                 'sub redefined in package dies';
+    eval_dies_ok q[module M { sub m { say "m" }; sub m { say "m" } }],
+                 'sub redefined in module dies';
+    #?rakudo 2 skip 'RT #68290'
+    eval_dies_ok q[grammar B { token b { 'b' }; token b { 'b' } };],
+                 'token redefined in grammar dies';
+    eval_dies_ok q[class C { method c { say "c" }; method c { say "c" } }],
+                 'method redefined in class dies';
+}
+
 #?rakudo todo 'RT #64688'
 {
     eval_lives_ok 'class RT64688_c1;use Test', 'use after class line';

@p6rt
Copy link
Author

p6rt commented Aug 12, 2009

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

@p6rt
Copy link
Author

p6rt commented May 14, 2010

From @moritz

FWIW, only the case of redefining a method in class isn't caught in
currently rakudo, it correctly dies in the other cases mentioned in this
ticket.

@p6rt
Copy link
Author

p6rt commented Sep 14, 2011

From @jnthn

On Fri May 14 08​:52​:43 2010, moritz wrote​:

FWIW, only the case of redefining a method in class isn't caught in
currently rakudo, it correctly dies in the other cases mentioned in this
ticket.

In latest Rakudo​:

class A { method m() { }; method m() { } }
Package 'A' already has a method 'm'; did you mean to declare a
multi-method?
sub a { }; sub a { }
Illegal redeclaration of routine 'a' at line 2, near ""

Seems to cover this ticket. Tagging testneeded.

/jnthn

@p6rt
Copy link
Author

p6rt commented Sep 14, 2011

From @tadzik

On Wed Sep 14 13​:46​:03 2011, jnthn@​jnthn.net wrote​:

Seems to cover this ticket. Tagging testneeded.

Tests available in
Raku/roast@f695da8e07.

Rakudo does not run t/spec/S12-methods/multi.t yet though, so maybe not
closable for now.

@p6rt
Copy link
Author

p6rt commented Sep 30, 2011

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

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