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

Anonymous classes are not quite as anonymous as one would wish in Rakudo #924

Closed
p6rt opened this issue Apr 20, 2009 · 6 comments
Closed

Comments

@p6rt
Copy link

p6rt commented Apr 20, 2009

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

Searchable as RT64888$

@p6rt
Copy link
Author

p6rt commented Apr 20, 2009

From @masak

<masak> rakudo​: sub foo() { return class { method Str() { return "OH
HAI" }; method Num() { return 42 } } }; say ~foo; say +foo
<p6eval> rakudo 480902​: OUTPUT«!ANON10␤Class !ANON10 already registered! [...]
<jnthn> Ugh. Anonymous classes are...not quite so anonmous as would be good.
<jnthn> file masakbug
<jnthn> *rakudobug
* masak files masakbug :)

@p6rt
Copy link
Author

p6rt commented Apr 22, 2009

From @pmichaud

On Mon, Apr 20, 2009 at 07​:58​:42AM -0700, Carl Mäsak wrote​:

<masak> rakudo​: sub foo() { return class { method Str() { return "OH
HAI" }; method Num() { return 42 } } }; say ~foo; say +foo
<p6eval> rakudo 480902​: OUTPUT«!ANON10␤Class !ANON10 already registered! [...]
<jnthn> Ugh. Anonymous classes are...not quite so anonmous as would be good.
<jnthn> file masakbug
<jnthn> *rakudobug
* masak files masakbug :)

That code looks to me as though it was attempting to define the class
twice. Obviously it should not be doing that here -- as the class
is an 'our' class and should therefore only happen once.

Pm

@p6rt
Copy link
Author

p6rt commented Apr 22, 2009

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

@p6rt
Copy link
Author

p6rt commented Aug 4, 2009

From @kyleha

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

commit 003f3f51c26dd19f6f7d4969f992d2727f9b034e
Author​: kyle <kyle@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Tue Aug 4 19​:37​:22 2009 +0000

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

Inline Patch
diff --git a/t/spec/S12-class/anonymous.t b/t/spec/S12-class/anonymous.t
index 5f87f25..9f3c1d1 100644
--- a/t/spec/S12-class/anonymous.t
+++ b/t/spec/S12-class/anonymous.t
@@ -3,7 +3,7 @@ use v6;
 use Test;
 
 # L<S12/Classes/"Perl 6 supports multiple inheritance, anonymous classes">
-plan 12;
+plan 16;
 
 # Create and instantiate empty class; check .WHAT works and stringifies to
 # empty string.
@@ -46,3 +46,24 @@ is($t3.x, 42,        'anonymous classes can have attributes');
     ok($x ~~ TestParent, 'anonymous class isa TestParent');
     is($x.foo, 42,       'inherited method from TestParent');
 }
+
+# RT #64888
+{
+    sub rt64888 {
+        (
+         class {
+             method Str() { 'RT #64888' }
+             method Num() { 64888 }
+         }
+        ).new
+    }
+    my $i1;
+    my $i2;
+
+    lives_ok { $i1 = rt64888() }, 'can get anonymous class instance once';
+    #?rakudo todo 'RT #64888'
+    lives_ok { $i2 = rt64888() }, 'can get anonymous class instance twice';
+
+    is ~$i1, 'RT #64888', 'anonymous class stringified works';
+    is +$i1, 64888, 'anonymous class numified works';
+}

@p6rt
Copy link
Author

p6rt commented Apr 21, 2010

From @jnthn

On Mon Apr 20 07​:58​:42 2009, masak wrote​:

<masak> rakudo​: sub foo() { return class { method Str() { return "OH
HAI" }; method Num() { return 42 } } }; say ~foo; say +foo
<p6eval> rakudo 480902​: OUTPUT«!ANON10␤Class !ANON10 already
registered! [...]
<jnthn> Ugh. Anonymous classes are...not quite so anonmous as would be
good.
<jnthn> file masakbug
<jnthn> *rakudobug
* masak files masakbug :)

Just fixed anonymous classes up in master and this issue is now happily
gone away...

sub foo() { return class { method Str() { return "OH HAI" }; method
Num() { return 42 } } }; say foo.Str; say foo.Num
OH HAI
42

Unfudged the spectest; closing ticket.

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Apr 21, 2010

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

@p6rt p6rt closed this as completed Apr 21, 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