www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8477] New: [2.060 beta] Strange error calling member func from overridden Exception::toString()

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

           Summary: [2.060 beta] Strange error calling member func from
                    overridden Exception::toString()
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: cbkbbejeap mailinator.com



15:35:04 PDT ---
class Foo : Exception
{
    this() { super(""); }

    int line()
    {
        return 0;
    }

    override string toString()
    {
        line();
        return "";
    }
}

Worked on 2.059. On 2.060 beta:

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

Problem goes away if Foo is *not* derived from Exception.

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


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

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



15:41:59 PDT ---
That means Exception has its toString defined as const thus your override also
must be const (and implicitly supposed to be).

Then it tries to call line and dies.

Marking lines as const fixes issue.

So it's either invalid report or request for better diagnostics.

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



15:49:37 PDT ---

 So it's either invalid report or request for better diagnostics.
Your second point is implicit as the numerous complaints show. But toString needs to be implemented with some consistency in Phobos.. Object.toString isn't const, but Throwable.toString is. What's it gonna be? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8477


Jonathan M Davis <jmdavisProg gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg gmx.com



PDT ---
 But toString needs to be implemented with some consistency in Phobos..
Object.toString isn't const, but Throwable.toString is. What's it gonna be?
We're going to move to a model where Object doesn't even _have_ toString on it. So, in the long run, the constancy of Object's toString is irrelevant, and since whether a particular type should have a const toString or not depends on the type and what it's doing, it's ultimately _not_ a question of consistency. I'd expect Throwable and its ilk to have a const toString in the long run. Whether it should be const right now or not, I don't know, since the issue with Object and its various functions is still being sorted out. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8477






 So it's either invalid report or request for better diagnostics.
Your second point is implicit as the numerous complaints show. But toString needs to be implemented with some consistency in Phobos.. Object.toString isn't const, but Throwable.toString is. What's it gonna be?
It's my mistake. I had reverted const qualifer of Object member functions, but forgotten about Throwable's. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 30 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8477


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
          Component|DMD                         |druntime
            Version|unspecified                 |D2



This is druntime issue.

https://github.com/D-Programming-Language/druntime/pull/284

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




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

https://github.com/D-Programming-Language/druntime/commit/6654dcfbaa23c1b64362c739914b8ba9bb098f05
fix Issue 8477 - [2.060 beta] Strange error calling member func from overridden
Exception::toString()

Revert const qualifier of Throwable.toString

https://github.com/D-Programming-Language/druntime/commit/7ff4fb1e37e00caa7187b39bda403377d888400d


Issue 8477 - [2.060 beta] Strange error calling member func from overridden
Exception::toString()

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


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

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


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


Jacob Carlborg <doob me.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |doob me.com



 We're going to move to a model where Object doesn't even _have_ toString on it.
Has there been some kind of official agreement on this? I followed the discussion and to me it looked more like it was going to be possible to have both const and non-const versions of the methods in Object. Is this only your opinion, were there a private discussion or have I just missed it? This is a big change and I really think these decisions need to be properly announced. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 31 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8477




PDT ---
It's official.

http://forum.dlang.org/post/jtlj1k$1fdj$1 digitalmars.com

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