Bug 5720 – Error messages for missing properties must be improved.

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-03-08T10:18:00Z
Last change time
2015-06-09T05:11:38Z
Assigned to
nobody
Creator
andrej.mitrovich

Comments

Comment #0 by andrej.mitrovich — 2011-03-08T10:18:35Z
This is a notorious error message that pops up from time to time due to human-nature (typos). Here's a trivial example: module test; void main() { auto foo = [4, 5, 6, 7]; assert(!foo.empty); } And the error: test.d(6): Error: undefined identifier module test.empty When a property is not found, the error message should reflect that there is no such property for symbol 'foo', instead of saying there's no identifier 'empty', which makes no sense at all (unless you count in UFCS, which comes into play here if you import std.array). I want this kind of error message to appear: test.d(6): Error: foo has no property 'empty' The above test case may be too trivial to notice just how damaging the original error message is. I've had a case in my code where I've had a couple of levels of pointer indirection (due to how a C library worked), I've had a typo and I was getting this same kind of error. It was quite frustrating to spend 30+ minutes on something as silly as a typo due to the error message pointing at something completely different. An error message that lies can be as bad as a lying comment in a piece of code. Can we improve this, please?
Comment #1 by andrej.mitrovich — 2011-03-08T15:44:33Z
Ok apparently this would just create confusion for UFCS users, and I would probably agree on this. I'm closing this one down for now.