Thread overview
[Issue 8549] New: Bad error message with const methods
Oct 20, 2012
Andrej Mitrovic
Oct 20, 2012
Andrej Mitrovic
Oct 20, 2012
Andrej Mitrovic
August 15, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8549

           Summary: Bad error message with const methods
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: bearophile_hugs@eml.cc


--- Comment #0 from bearophile_hugs@eml.cc 2012-08-15 06:07:31 PDT ---
This needs a much better error message:


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



DMD 2.061alpha gives:

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

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


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-10-19 20:57:41 PDT ---
Issue6707 covers this, the error message is now:

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

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

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



--- Comment #2 from bearophile_hugs@eml.cc 2012-10-19 21:36:07 PDT ---
(In reply to comment #1)
> Issue6707 covers this, the error message is now:

I agree with closing this as dupe.

But I think adding "const" at the end is not nearly enough to make the error message clear.

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



--- Comment #3 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-19 21:40:56 PDT ---
(In reply to comment #2)
> (In reply to comment #1)
> > Issue6707 covers this, the error message is now:
> 
> I agree with closing this as dupe.
> 
> But I think adding "const" at the end is not nearly enough to make the error message clear.

I would take a bigger pull to fix this since there's a lot of code duplication in DMD. Personally I would change the message to:

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

What do you think?

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



--- Comment #4 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2012-10-19 21:41:21 PDT ---
(In reply to comment #3)
> I would take

*It* would take.

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



--- Comment #5 from bearophile_hugs@eml.cc 2012-10-20 22:42:12 PDT ---
(In reply to comment #3)

> I would take a bigger pull to fix this since there's a lot of code duplication in DMD. Personally I would change the message to:
> 
> Error: function test.Foo.opSlice () is not callable using const(this)
> 
> What do you think?

Do you want me to reopen this bug report?

Maybe an error message that tells what to do is better (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: -------
October 21, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8549



--- Comment #6 from bearophile_hugs@eml.cc 2012-10-21 14:10:56 PDT ---
(In reply to comment #5)

> Do you want me to reopen this bug report?

I have reopened Issue 6707 instead.

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