204 – Error message on attempting to instantiate an abstract class needs to be improved

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 204 - Error message on attempting to instantiate an abstract class needs to be improved
Summary: Error message on attempting to instantiate an abstract class needs to be impr...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: Walter Bright
URL:
Keywords: diagnostic
Depends on:
Blocks:
Reported: 2006年06月17日 14:32 UTC by Dawid Ciężarkiewicz
Modified: 2015年06月09日 05:15 UTC (History)
4 users (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Dawid Ciężarkiewicz 2006年06月17日 14:32:47 UTC
map.d(165): cannot create instance of abstract class Droid
Please add info about method which isn't implemented yet: "because XXX is abstract" or smth. If many - the first one is good enought.
Comment 1 Matti Niemenmaa 2006年06月18日 10:09:01 UTC
To show the issue more clearly:
--
class Foo { abstract void foo(); }
class Bar : Foo {}
void main() {
	Bar bar = new Bar();
}
--
The code fails with "cannot create instance of abstract class Bar". What is being asked for is an error message which would, in this instance, clarify that the reason the instantiation fails is that the method foo() is unimplemented in Bar.
Comment 2 Bradley Smith 2006年09月28日 17:11:08 UTC
I think this is an important usability/productivity issue. Althought I don't know the internals of the DMD compiler, I would expect the compiler to know what is missing before deciding it can't create an instance. Therefore it should be a simple matter to add that information to the error message.
In addition, I think this gives DMD, and hence the D language, a feeling of incompleteness. Something which may be a hinderance to wider usage.
Comment 3 Brad Roberts 2007年01月27日 01:34:48 UTC
This is represented by dstress test:
http://dstress.kuehne.cn/nocompile/a/abstract_14.d 
Comment 4 Stewart Gordon 2007年01月27日 08:00:47 UTC
// __DSTRESS_ELINE__ 19
Why line 19? Why not 16, where the abstract method is declared?
Comment 5 Frits van Bommel 2007年01月27日 09:57:44 UTC
(In reply to comment #4)
> // __DSTRESS_ELINE__ 19
> 
> Why line 19? Why not 16, where the abstract method is declared?
I'd prefer both: 16 to indicate *which* abstract method isn't declared, and 19 to indicate *where* it isn't declared.
Comment 6 Frits van Bommel 2007年01月27日 10:09:49 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > // __DSTRESS_ELINE__ 19
> > 
> > Why line 19? Why not 16, where the abstract method is declared?
> 
> I'd prefer both: 16 to indicate *which* abstract method isn't declared, and 19
> to indicate *where* it isn't declared.
s/declared/implemented/g
(For the less sed-aware: replace both instances of "declared" in above comment with "implemented")
Comment 7 Matti Niemenmaa 2007年11月28日 02:27:45 UTC
Fixed in 1.024.
Comment 8 Walter Bright 2007年12月04日 23:34:38 UTC
Fixed dmd 1.024 and 2.008


AltStyle によって変換されたページ (->オリジナル) /