Bug 3012 – Bad error message when using string.format instead of std.string.format
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2009-05-20T04:42:00Z
Last change time
2015-06-09T01:27:45Z
Keywords
diagnostic
Assigned to
nobody
Creator
davidl
Comments
Comment #0 by davidl — 2009-05-20T04:42:42Z
testd:
import std.string;
void main()
{
string s= string.format("abc","abc");
}
TypeExp::toElem()
testd.d(5): Error: type immutable(char)[] is not an expression
Comment #1 by gide — 2009-05-20T05:06:34Z
> string s= string.format("abc","abc");
Shouldn't that be std.string.format? I think what is written is equalivent to;
format(string,"abc","abc");
import std.string;
void main()
{
string s = std.string.format("abc","abc"); //OK
// -or-
string s1 = format("abc","abc"); //OK
}
Comment #2 by davidl — 2009-05-20T06:21:35Z
err.. i didn't figure out the real meaning of that error message..
Maybe it'd better tell me in what context I did wrong.
Comment #3 by davidl — 2009-05-20T10:51:59Z
I change this bug to enhancement request for better diagnose.
TypeExp::toElem() //redundent
testd.d(5): Error: type immutable(char)[] is not an expression
// not clear enough for one to figure out it rewrites it to format(string, "abc", "abc"); At least for me in this case. I don't think D newbies can easily get the idea of this error message correctly.
Comment #4 by gide — 2009-05-20T14:54:03Z
Agreed it is confusing. I've changed title and added diagnostic keyword.
Comment #5 by andrej.mitrovich — 2012-10-20T10:00:26Z
Error is now:
test.d(5): Error: no property 'format' for type 'string'
This is clear enough now.