digitalmars.D.bugs - [Issue 1621] New: cannot access string member in const method
- d-bugmail puremagic.com (28/28) Oct 28 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1621
- d-bugmail puremagic.com (4/4) Nov 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1621
- d-bugmail puremagic.com (9/9) Mar 01 2008 http://d.puremagic.com/issues/show_bug.cgi?id=1621
http://d.puremagic.com/issues/show_bug.cgi?id=1621 Summary: cannot access string member in const method Product: D Version: 2.006 Platform: PC OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: i.kasiuk gmx.de Maybe I just don't understand const and invariant properly. But I wonder why the following code doesn't compile: class A { string s; const string f() { return s; } } The error message is: test.d(3): Error: cannot implicitly convert expression (this.s) of type const char[] to invariant(char)[] Why does it state that s is of type const char[]? Shouldn't it be const invariant(char)[]? Replacing "return s;" by "return cast(string) s;" fixes the compilation error. But why do I have to cast s to its own type? The compilation error also disappears if the method is invariant instead of const. --
Oct 28 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1621 ------- Comment #1 from i.kasiuk gmx.de 2007-11-23 14:09 ------- This seems to be fixed in DMD 2.007. --
Nov 23 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1621 i.kasiuk gmx.de changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from i.kasiuk gmx.de 2008-03-01 12:34 ------- fixed in >=2.007 --
Mar 01 2008