Bug 9128 – Better error message for method-level/instance-level name confusions

Status
RESOLVED
Resolution
DUPLICATE
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-09T09:33:00Z
Last change time
2012-12-10T09:06:50Z
Keywords
diagnostic
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-12-09T09:33:55Z
This program: struct Foo { void bar() { int spam; // Some stuff here. this.spam++; } } void main() {} DMD2.061alpha gives: test.d(5): Error: undefined identifier 'spam' Here spam is a method-level name instead of a instance-level attribute. In complex methods that error message doesn't give enough help. So I suggest a better error message, something like: test.d(4): Error: undefined identifier 'this.spam', did you mean 'spam'? Other error messages are possible, that mention more explicitly that there is a method-level identifier with the same name.
Comment #1 by andrej.mitrovich — 2012-12-10T09:06:22Z
The root cause of this is the 2.069 regression in Issue 8894. There's a pull waiting for it. *** This issue has been marked as a duplicate of issue 8894 ***
Comment #2 by andrej.mitrovich — 2012-12-10T09:06:50Z
(In reply to comment #1) > The root cause of this is the 2.069 regression in Issue 8894. There's a pull > waiting for it. > > *** This issue has been marked as a duplicate of issue 8894 *** I meant 2.059 regression (I don't time-travel, I swear!)