www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1730] New: const struct member func return invariant string can't assign to invariant string

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

           Summary: const struct member func return invariant string can't
                    assign to invariant string
           Product: D
           Version: 2.008
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: davidl 126.com


struct mystruct{
        invariant(char)[] toChars()
        {
                return "asdf";
        }
}
void func(in mystruct s)
{
        invariant(char)[] k=s.toChars;
}

testconst.d(9): function testconst.mystruct.toChars () does not match parameter
types ()
testconst.d(9): Error: s.toChars can only be called on a mutable object, not
const(mystruct)


-- 
Dec 13 2007
next sibling parent "Janice Caron" <caron800 googlemail.com> writes:
On 12/14/07, d-bugmail puremagic.com <d-bugmail puremagic.com> wrote:
 struct mystruct{
         invariant(char)[] toChars()
         {
                 return "asdf";
         }
 }
 void func(in mystruct s)
 {
         invariant(char)[] k=s.toChars;
 }
That's correct behaviour, surely? Change the function definition to const invariant(char)[] toChars() { return "asdf"; } and the problem should go away. toChars() as written is incorrectly declared. It does not modify this, therefore it should be declared const. That said, I don't understant how s got to be const in the first place! Does "in" make things const?
Dec 13 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730


davidl 126.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
           Keywords|rejects-valid               |
            Summary|const struct member func    |error message enhance?
                   |return invariant string     |
                   |can't assign to invariant   |
                   |string                      |




------- Comment #2 from davidl 126.com  2007-12-15 07:40 -------
But at least the first error message is confusing.


-- 
Dec 15 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730



--- Comment #3 from Stewart Gordon <smjg iname.com> 2009-11-20 11:10:48 PST ---
Probably part of the same bug:

----------
class Class {
    void fn1() const {
        fn2();
    }

    void fn2() {}
}
----------
const_call.d(3): Error: function const_call.Class.fn2 () is not callable using
argument types () const
----------

This may make sense at the internal level, as trying to convert the 'this'
argument implicitly from const(Class) to Class.  But as a user error message,
it's confusing.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 20 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730


Michal Spadlinski <gim913 gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gim913 gmail.com


--- Comment #4 from Michal Spadlinski <gim913 gmail.com> 2010-03-13 07:25:52
PST ---
I has similar problem with:

struct Foo {
    bool boo() {
        return false;
    }

    int foo () const {
        assert (boo);
        return 66;
    }
}

this message is totally misleading

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 13 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason.james.house gmail.com


--- Comment #5 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-23
13:45:29 PST ---
*** Issue 3642 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 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool gmx.de


--- Comment #6 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-23
13:45:34 PST ---
*** Issue 4497 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 23 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730


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

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


--- Comment #7 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-23
13:47:23 PST ---
There's a ton of duplicate reports on this diagnostic. We better come up with a
better error message than what we have now because there's a lot of complaints.

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


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

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


--- Comment #8 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-25
06:31:46 PST ---
https://github.com/D-Programming-Language/dmd/pull/1407

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



--- Comment #9 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-27
17:43:17 PST ---
*** Issue 6707 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 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730



--- Comment #10 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-27
17:50:19 PST ---
*** Issue 6981 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 27 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730



--- Comment #11 from github-bugzilla puremagic.com 2013-01-02 23:18:49 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/80d12f303c6184c9423a08b6d984db469ec27927
Fix Issue 1730 - Error message on 'this' reference modifier mismatch when
calling methods is uninformative

https://github.com/D-Programming-Language/dmd/commit/99e93a62383a627497d7eafbee772b99329cb70f
Merge pull request #1407 from AndrejMitrovic/Fix1730

Issue 1730 - Error message on 'this' reference modifier mismatch is
uninformative

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 02 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1730


Andrej Mitrovic <andrej.mitrovich 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: -------
Jan 20 2013