www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6707] New: Error message for mismatch of const/non-const property functions needs to improve

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707

           Summary: Error message for mismatch of const/non-const property
                    functions needs to improve
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



08:44:17 PDT ---
struct Foo
{
    int payload;

     property void value(int x) { payload = x;}
     property int value() { return payload; }

    const bool opEquals(ref const(Foo) other)
    {
        return this.value == other.value;
    }        
}

void main() { }

This errors with: 
Error: function test.Foo.value (int x) is not callable using argument types ()
The solution is to add a const property function like this one:

 property const(int) value() const { return payload; }

But this can't be easily figured out from that error message.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 21 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707




12:56:30 PDT ---
Better test case:

struct Foo
{
     property bool value() { return true; }

    void test() const
    {
        auto x = value;   // not callable using argument types ()
        auto y = value(); // not callable using argument types () const
    }
}

void main() { }

It seems 'this' for property func isn't printed out properly unless it's called
as a function, I'll see if this is fixable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 04 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d123b58057a8116d3549418551ed7ea03f9c46cd
Fixes Issue 6707

https://github.com/D-Programming-Language/dmd/commit/b022c3c66616600cdf349d53d32983774b72fdbd


Fix Issue 6707 - Print better error message on const property mismatch

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707


Brad Roberts <braddr puremagic.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |braddr puremagic.com
         Resolution|                            |FIXED


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 08 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



20:57:42 PDT ---
*** Issue 8549 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 19 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |
           Severity|normal                      |enhancement



I reopen this as enhancement request because I think the error message is not
good enough still. See Issue 8549 for more info.

This program:


struct Foo {
    int[] opSlice() {
        return [0];
    }
}
struct Bar {
    Foo spam;
    const(Foo) bar() const { return spam; }
}
void main() {
    Bar().bar()[];
}


Currently gives:

test.d(11): Error: function test.Foo.opSlice () is not callable using argument
types () const


In Issue 8549 Andrej Mitrovic suggests an error message similar to:

Error: function test.Foo.opSlice () is not callable using const(this)


But I think a better error message, more newbie-friendly, tells the programmer
how to fix the problem, (not complete error message):

test.d(11): Error: function test.Foo.opSlice() needs to be const to [...]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707




14:15:14 PDT ---

 But I think a better error message, more newbie-friendly, tells the programmer
 how to fix the problem, (not complete error message):
 
 test.d(11): Error: function test.Foo.opSlice() needs to be const to [...]
If it's in a 3rd party library then the user has no other choice but to use a const object. I don't think we should start recommending to rewrite code like that, especially to newbies. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707






 If it's in a 3rd party library then the user has no other choice but to use a
 const object. I don't think we should start recommending to rewrite code like
 that, especially to newbies.
I understand. Time ago I have seen this error message and it took me some some to understand what's the problem. So I've asked for a simpler to understand error message. If you think my suggestion is not good, then do something different :-) Maybe we should ask to more people in the D newsgroup. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 21 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla kyllingen.net



08:57:39 PST ---
*** Issue 9132 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |DUPLICATE



17:43:17 PST ---
The pull for Issue 1730 will likely resolve your issue of the unreadable error
message.

*** This issue has been marked as a duplicate of issue 1730 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 27 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6707


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dmitry.olsh gmail.com



*** Issue 8552 has been marked as a duplicate of this issue. ***

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