Thread overview
[Issue 9128] New: Better error message for method-level/instance-level name confusions
Dec 10, 2012
Andrej Mitrovic
Dec 10, 2012
Andrej Mitrovic
December 09, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9128

           Summary: Better error message for method-level/instance-level
                    name confusions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-12-09 09:33:55 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9128


Andrej Mitrovic <andrej.mitrovich@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |DUPLICATE


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-10 09:06:22 PST ---
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 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 10, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9128



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-12-10 09:06:50 PST ---
(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!)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------