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

a memory error occurs when the a method overridden in an 'is also' class declaration is called in Rakudo #1073

Closed
p6rt opened this issue Jun 18, 2009 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 18, 2009

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

Searchable as RT66694$

@p6rt
Copy link
Author

p6rt commented Jun 18, 2009

From @masak

<masak> rakudo​: class Failure is also { method foo {say "OH HAI"} }; .foo
<p6eval> rakudo 9dc941​: OUTPUT«OH HAI␤»
<moritz_> new in Perl 6​: extensinble undef!
<masak> rakudo​: class Failure is also { method defined { True } }; say .defined
<p6eval> rakudo 9dc941​: ( no output )
* masak snickers
<masak> that one gives a bus error on my box.
<moritz_> it's what happens when a program tries to use memory outside
of its address range
<masak> rakudo​: class Failure is also { method perl { "HOLA!" } }; say .perl
<p6eval> rakudo 9dc941​: ( no output )
<masak> seems the problem is in overriding methods that were defined already.
<moritz_> "no output" is wrong though
<masak> moritz_​: yes. that's what I mean.
<moritz_> ah yes, it's a segfault
<moritz_> which, for whatever reasons, is printed to the console, not to IRC
<masak> "no output" here means that a bus error occurred.
<masak> rakudo​: class A { method foo { 1 } }; class A is also { method
foo { 2 } }; A.new.foo
<p6eval> rakudo 9dc941​: ( no output )
<masak> ah.
<masak> and it's not just PIR methods.
* masak submits rakudobug

@p6rt
Copy link
Author

p6rt commented Aug 9, 2010

From @coke

On Thu Jun 18 04​:24​:13 2009, masak wrote​:

<masak> rakudo​: class Failure is also { method foo {say "OH HAI"} };
.foo
<p6eval> rakudo 9dc941​: OUTPUT«OH HAI␤»
<moritz_> new in Perl 6​: extensinble undef!
<masak> rakudo​: class Failure is also { method defined { True } }; say
.defined
<p6eval> rakudo 9dc941​: ( no output )
* masak snickers
<masak> that one gives a bus error on my box.
<moritz_> it's what happens when a program tries to use memory outside
of its address range
<masak> rakudo​: class Failure is also { method perl { "HOLA!" } }; say
.perl
<p6eval> rakudo 9dc941​: ( no output )
<masak> seems the problem is in overriding methods that were defined
already.
<moritz_> "no output" is wrong though
<masak> moritz_​: yes. that's what I mean.
<moritz_> ah yes, it's a segfault
<moritz_> which, for whatever reasons, is printed to the console, not
to IRC
<masak> "no output" here means that a bus error occurred.
<masak> rakudo​: class A { method foo { 1 } }; class A is also { method
foo { 2 } }; A.new.foo
<p6eval> rakudo 9dc941​: ( no output )
<masak> ah.
<masak> and it's not just PIR methods.
* masak submits rakudobug

< [Coke]> rakudo​: use MONKEY_TYPING; augment class Failure { method
  defined { True } }; say .defined
<+p6eval> rakudo c1e19a​: OUTPUT«===SORRY!===␤A method named 'defined'
  already exists in class 'Failure'. It may have been supplied by
  a role.␤»

< [Coke]> rakudo​: use MONKEY_TYPING; class A { method foo { 1 } };
  augment class A { method foo { 2 } }; A.new.foo
<+p6eval> rakudo c1e19a​: OUTPUT«===SORRY!===␤A method named 'foo' already
  exists in class 'A'. It may have been supplied by a role.␤»

This looks much saner. Assigning to moritz++ for testing.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 9, 2010

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

@p6rt
Copy link
Author

p6rt commented Aug 19, 2010

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

@p6rt p6rt closed this as completed Aug 19, 2010
@p6rt
Copy link
Author

p6rt commented Aug 19, 2010

From @kyleha

This is an automatically generated mail to inform you that tests are now available in t/spec/S12-class/augment-supersede.t

commit 832c1a0d999adb004e37f460c44b8b357fc61b09
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Thu Aug 19 19​:23​:01 2010 +0000

  [t/spec] test for RT #​66694, redefining methods by augmenting stuff
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;32060 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S12-class/augment-supersede.t b/t/spec/S12-class/augment-supersede.t
index 1230032..b4e07f2 100644
--- a/t/spec/S12-class/augment-supersede.t
+++ b/t/spec/S12-class/augment-supersede.t
@@ -2,7 +2,7 @@ use v6;
 
 use Test;
 
-plan 5;
+plan 6;
 
 # L<S12/"Open vs Closed Classes"/"Otherwise you'll get a class redefinition error.">
 
@@ -23,6 +23,12 @@ use MONKEY_TYPING;
     ok(!eval('augment class NonExistent { }'), 'augment on non-existent class dies');
 }
 
+# RT #66694
+eval_dies_ok q[
+    class MethodClash { method foo() { 3 } };
+    augment class MethodClash { method foo() { 3 } };
+], 'cannot override a method by monkey-typing';
+
 #?rakudo skip 'supersede'
 {
     class Bar {

@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