[Issue 6553] New: Better const(char[]) !-> string error message
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 24 20:50:24 PDT 2011
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 at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at 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: -------
More information about the Digitalmars-d-bugs
mailing list