Thread overview | |||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
December 14, 2007 [Issue 1730] New: const struct member func return invariant string can't assign to invariant string | ||||
---|---|---|---|---|
| ||||
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) -- |
December 14, 2007 Re: [Issue 1730] New: const struct member func return invariant string can't assign to invariant string | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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?
|
December 15, 2007 [Issue 1730] error message enhance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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. -- |
November 20, 2009 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
March 13, 2010 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
December 23, 2012 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
December 23, 2012 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
December 23, 2012 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
December 25, 2012 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
December 28, 2012 [Issue 1730] Bogus error message calling a non-const struct method on a const struct reference | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | 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: ------- |
Copyright © 1999-2021 by the D Language Foundation