digitalmars.D.bugs - [Issue 6553] New: Better const(char[]) !-> string error message
- d-bugmail puremagic.com (47/47) Aug 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6553
- d-bugmail puremagic.com (10/10) Dec 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6553
- d-bugmail puremagic.com (17/18) Dec 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6553
- d-bugmail puremagic.com (8/9) Dec 27 2012 http://d.puremagic.com/issues/show_bug.cgi?id=6553
http://d.puremagic.com/issues/show_bug.cgi?id=6553 Summary: Better const(char[]) !-> string error message Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Keywords: diagnostic Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: bearophile_hugs eml.cc --- Comment #0 from bearophile_hugs eml.cc 2011-08-24 20:50:22 PDT --- This is related to bug 5081 , see there for more context. I think the behaviours shown by this little program are correct, but I think that error message needs to be improved (completed with more details), because in some cases (like foo1) that's an acceptable operation (dmd 2.055 head): string foo1() pure { const(char[]) s2 = ['a']; return s2; } string foo2() pure { return ['a']; } string foo3(immutable char[] s) pure { return s; } string foo4(in char[] s1, immutable char[] s2) pure { return s2; } string foo5(in char[] s) pure { return s; // Error: cannot implicitly convert expression (s) of type const(char[]) to string } void main() { immutable r1 = foo1(); // OK immutable r2 = foo2(); // OK immutable r3 = foo3(['a']); // OK immutable r4 = foo4(['a'], ['b']); // OK immutable r5 = foo5(['a']); // Error } Good and complete error messages are needed to help the programmer understand her mistake and build a correct model of D semantics in her head. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 24 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6553 Andrej Mitrovic <andrej.mitrovich gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrej.mitrovich gmail.com --- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-12-27 17:52:42 PST --- All of these compile in 2.061. Got any other test-cases or should we close? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6553 --- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2012-12-27 18:50:09 PST --- (In reply to comment #1)All of these compile in 2.061. Got any other test-cases or should we close?Wait, the conversion in foo5 should fail correctly. If it is allowed, following code will accidentally break const-correctness. void main() { char[] buf = ['a']; immutable str = foo5(buf); assert(str[0] == 'a'); buf[0] = 'b'; assert(str[0] == 'a'); // fails!? } And this code compiles without errors in current git head. I think this is a regression. Will open a new issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 27 2012
http://d.puremagic.com/issues/show_bug.cgi?id=6553 --- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2012-12-27 19:02:58 PST --- (In reply to comment #2)I think this is a regression. Will open a new issue.Opened: Issue 9230 - Incorrect implicit immutable conversion occurs in pure function -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 27 2012