Bug 9635 – Improved error message for failed access of array field properties from static method
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-02T12:08:00Z
Last change time
2013-03-05T11:29:57Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2013-03-02T12:08:03Z
Spinoff of issue 9630
This program:
struct Foo {
int i[1];
static void bar() {
assert(0 < i[0].max);
}
}
Currently gives:
temp.d(4): Error: need 'this' for i type int[1u].
Andrej Mitrovic suggests:
> This is already a bad message. 'i' should be quoted and the wording should be
> improved:
> temp.d(4): Error: need 'this' for 'i' of type int[1u]
Is it possible to generate an error message like this, that suggests how to fix the problem?
temp.d(4): Error: need 'this' for 'i' of type int[1u]. Use typeof(i[0]).max instead
Comment #1 by andrej.mitrovich — 2013-03-04T20:32:13Z
(In reply to comment #0)
> Is it possible to generate an error message like this, that suggests how to fix
> the problem?
>
> temp.d(4): Error: need 'this' for 'i' of type int[1u]. Use typeof(i[0]).max
> instead
This could end up being arbitrarily hard to implement, so I'll just improve the wording of the error message like I've mentioned.
https://github.com/D-Programming-Language/dmd/pull/1721
Comment #2 by github-bugzilla — 2013-03-05T05:57:18Z