Bug 10449 – Better error message when concatenating string
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-23T04:00:00Z
Last change time
2015-06-12T05:11:34Z
Keywords
diagnostic
Assigned to
nobody
Creator
michal.minich
Comments
Comment #0 by michal.minich — 2013-06-23T04:00:16Z
void main ()
{
auto x = "str1" ~
~ "str2"; // Error: '"str2"' is not of integral type, it is a string
}
Next time I will know, but it is quite confusing, it should say.
"prefix operator '~' can be applied only to integral type, not to a string. If you are trying to concatenate string then check for redundant '~'."
Comment #1 by k.hara.pg — 2015-06-12T05:11:34Z
From 2.065, the message is changed.
With git-head (2.068a), it prints:
test.d(4): Error: invalid array operation ~"str2" (possible missing [])
It shows the applied prefix operator `~` in message, so I think it's improved.