Skip Menu |
Report information
Id: 122232
Status: resolved
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



From: Carl Mäsak <cmasak [...] gmail.com>
Date: Sat, 5 Jul 2014 13:43:37 +0200
Subject: [BUG] LTA error message for trying to instantiate non-class
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 1.6k
<masak> m: class A::B {}; say A.new <camelia> rakudo-moar 44d535: OUTPUT«You cannot create an instance of this type [...] <masak> ^^ might want a clearer error message. <jnthn> Including the name rather than "this type" would help, but there's no good way to get hold of it at the moment. * masak submits rakudobug <masak> m: module A {}; say A.new <camelia> rakudo-moar 44d535: OUTPUT«You cannot create an instance of this type [...] <masak> m: class A::B {}; say A.HOW.^name <camelia> rakudo-moar 44d535: OUTPUT«Perl6::Metamodel::PackageHOW␤» <masak> jnthn: if we just changed the error message to "You tried to call .new on a package", what wouldn't work out so well? <jnthn> we don't know it's a package <jnthn> m: subset Foo of Int where * > 42; Foo.new <camelia> rakudo-moar 44d535: OUTPUT«You cannot create an instance of this type [...] <masak> ok, fair enough. <masak> I suspected something like that might be the case. <jnthn> There's an Uninstantiable REPR at the bottom of all these. <masak> *nod* <masak> but still, an error message saying "Tried to instantiate A but it is a {A.HOW.^name}" would be ideal, no? <jnthn> but it isn't a PackageHOW, it's a Package. And you can't make a method call in a REPR. That's against the rules. <masak> oh :/ <masak> then I don't know of a good solution. <jnthn> Don't "oh :/". Those rules keep a dozen other things sane. <masak> it wasn't disappointment at the rule as such. I'm sure it's a great rule. <masak> it was disappointment at the fact that there isn't an easy fix. <jnthn> If there's any fix, it's to do what method dispatch does, which is let the HLL supply a handler for such errors, so it can rewrite them cleanly into some other exception type. <masak> ok.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org