[Issue 12954] New: deprecated doesn't work with concatenated strings or anything else but a string literal
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Jun 19 23:15:42 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12954
Issue ID: 12954
Summary: deprecated doesn't work with concatenated strings or
anything else but a string literal
Product: D
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: jmdavisProg at gmx.com
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).
--
More information about the Digitalmars-d-bugs
mailing list