Bug 12954 – deprecated doesn't work with concatenated strings or anything else but a string literal
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-06-20T06:15:42Z
Last change time
2020-05-18T12:43:34Z
Assigned to
No Owner
Creator
Jonathan M Davis
Comments
Comment #0 by issues.dlang — 2014-06-20T06:15:42Z
This code:
deprecated("my " ~ "message")
void foo()
{
}
void main()
{
}
gives this error
q.d(1): Error: string expected, not '"my " ~ "message"'
This code gives a similar error:
string bar()
{
return "my message";
}
deprecated(bar())
void foo()
{
}
void main()
{
}
I would have expected that deprecated would take any arbitrary expression which evaluated to a string at compile time. I'm not sure that it really matters that you can pass it a function (save for consistency with other language features), but the lack of ~ makes it hard to break up lines if you end up with a long deprecation message (and yes, it's generally better to have shorter deprecation messages, but sometimes longer ones are required, and it would be better if they didn't have to be on one, overly long line).
Comment #1 by pro.mathias.lang — 2015-12-06T21:44:54Z