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

non-awesome error message on 'class NewClass does OldClass' #1123

Closed
p6rt opened this issue Jul 7, 2009 · 9 comments
Closed

non-awesome error message on 'class NewClass does OldClass' #1123

p6rt opened this issue Jul 7, 2009 · 9 comments

Comments

@p6rt
Copy link

p6rt commented Jul 7, 2009

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

Searchable as RT67278$

@p6rt
Copy link
Author

p6rt commented Jul 7, 2009

From @moritz

08​:53 <@​moritz_> rakudo​: class A { }; class B does A { }; say "alive"
08​:53 < p6eval> rakudo 99ad1e​: OUTPUT«Method '!select' not found for
invocant of class ''␤»

I think abusing a class as a role is forbidden, but the error message
could be more awesome.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 7, 2009

From @chromatic

On Monday 06 July 2009 23​:55​:28 Moritz Lenz wrote​:

I think abusing a class as a role is forbidden

I hope it's not!

-- c

@p6rt
Copy link
Author

p6rt commented Jul 7, 2009

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

@p6rt
Copy link
Author

p6rt commented Jul 7, 2009

From @moritz

chromatic wrote​:

On Monday 06 July 2009 23​:55​:28 Moritz Lenz wrote​:

I think abusing a class as a role is forbidden

I hope it's not!

Well, it surely depends on context. You can "pun" a role into a class by
instantiating it, but the correct way to apply it to another class seems
to be with 'does', not 'is'.

I haven't found a concrete reference in the specs if it's actually
forbidden, a comment from jnthn or TimToady would be appreciated.

Cheers,
Moritz

@p6rt
Copy link
Author

p6rt commented Jul 8, 2009

From @jnthn

Moritz Lenz wrote​:

chromatic wrote​:

On Monday 06 July 2009 23​:55​:28 Moritz Lenz wrote​:

I think abusing a class as a role is forbidden

I hope it's not!

Well, it surely depends on context. You can "pun" a role into a class by
instantiating it, but the correct way to apply it to another class seems
to be with 'does', not 'is'.

As it stands right now...

class C does R { } # composes the role
class C is R { } # inherits from the pun
class C1 is C2 { } # plain old class inheritance
class C1 does C2 { } # fails

I haven't found a concrete reference in the specs if it's actually
forbidden, a comment from jnthn or TimToady would be appreciated.

I've heard the whole "every class implies a role" and "you can take a
role as an immutable snapshot of a class" stuff touted now and then, but
as moritz points out, there's nothing concrete in the spec about that.
Unless that changes (which I'm open to it doing), don't expect Rakudo's
current semantics to change on this (aside from awesomizing the error
message).

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented Apr 22, 2010

From @jnthn

On Mon Jul 06 23​:55​:28 2009, moritz wrote​:

08​:53 <@​moritz_> rakudo​: class A { }; class B does A { }; say "alive"
08​:53 < p6eval> rakudo 99ad1e​: OUTPUT«Method '!select' not found for
invocant of class ''␤»

While at some point we may end up spec'ing that you actually get your
class snapshotted to make a role, that's not the case yet. So I
awesomized the error​:

class A { }; class B does A { }
Can only use does with a role, but A is not one

Giving to moritz++ for spectests (I guess one to check that we get an
error mentioning A will do fine).

Thanks,

Jonathan

@p6rt
Copy link
Author

p6rt commented May 24, 2010

From @kyleha

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

commit 4b8222394636ac4bb66f3661dfa9cee5dc0f30b2
Author​: moritz <moritz@​c213334d-75ef-0310-aa23-eaa082d1ae64>
Date​: Mon May 24 14​:46​:29 2010 +0000

  [t/spec] tests for RT #​67278, non-awesome error message for class Foo does NonRole
 
  git-svn-id​: http://svn.pugscode.org/pugs@&#8203;30777 c213334d-75ef-0310-aa23-eaa082d1ae64

Inline Patch
diff --git a/t/spec/S14-roles/basic.t b/t/spec/S14-roles/basic.t
index 405e2ba..9d48c95 100644
--- a/t/spec/S14-roles/basic.t
+++ b/t/spec/S14-roles/basic.t
@@ -114,6 +114,15 @@ eval_dies_ok '0 but RT66178', '"but" with non-existent role dies';
        '... and the error message mentions the role';
 }
 
+# RT #67278
+{
+    class AClass { };
+    my $x = eval 'class BClass does AClass { }; 1';
+    nok $x, 'class SomeClass does AnotherClass  dies';
+    ok "$!" ~~ /AClass/, 'Error message mentions the offending non-role';
+
+}
+
 done_testing;
 
 # vim: ft=perl6

@p6rt
Copy link
Author

p6rt commented May 24, 2010

From @moritz

... and now tested appropriately.

@p6rt
Copy link
Author

p6rt commented May 24, 2010

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

@p6rt p6rt closed this as completed May 24, 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