Thread overview
[Issue 9635] New: Improved error message for failed access of array field properties from static method
Mar 05, 2013
Andrej Mitrovic
Mar 05, 2013
Andrej Mitrovic
March 02, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9635

           Summary: Improved error message for failed access of array
                    field properties from static method
           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 2013-03-02 12:08:03 PST ---
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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9635


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |andrej.mitrovich@gmail.com
         AssignedTo|nobody@puremagic.com        |andrej.mitrovich@gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-04 20:32:13 PST ---
(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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9635



--- Comment #2 from github-bugzilla@puremagic.com 2013-03-05 05:57:18 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/49c26139d40f3c89983a1a361b15b00f63291f5e Fixes Issue 9635 - Improve message on missing this diagnostics.

https://github.com/D-Programming-Language/dmd/commit/d6db1b834c24422bd28984760f662a6a37df234e Merge pull request #1721 from AndrejMitrovic/Fix9635

Issue 9635 - Improve message on missing 'this' diagnostics.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9635


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


--- Comment #3 from bearophile_hugs@eml.cc 2013-03-05 10:08:40 PST ---
If you think it's too much hard to implement, then I close this down. I use WONTFIX then.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
March 05, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9635


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|WONTFIX                     |FIXED


--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-03-05 11:29:57 PST ---
Open it up as a new enhancement for later, I might look into it when I have the time. Let this one be fixed since a fix was implemented.

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