D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 12954 - deprecated doesn't work with concatenated strings or anything else but a string literal
Summary: deprecated doesn't work with concatenated strings or anything else but a stri...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords:
: 16014 (view as issue list)
Depends on:
Blocks:
 
Reported: 2014-06-20 06:15 UTC by Jonathan M Davis
Modified: 2020-05-18 12:43 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jonathan M Davis 2014-06-20 06:15:42 UTC
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 Mathias LANG 2015-12-06 21:44:54 UTC
P.R. submitted: https://github.com/D-Programming-Language/dmd/pull/5302
Comment 2 github-bugzilla 2016-02-10 04:46:23 UTC
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/f04dc8b916ccd3e3139ce4192d2365597614e77b
Fix issue 12954 - Deprecated only works with string literals

Allow code to use `enum` and `static {immutable,const}` for the deprecation message.
This will allow for more dynamic deprecation message (e.g. with release informations).
It purposedly doesn't support direct function call to get the deprecation message.

https://github.com/D-Programming-Language/dmd/commit/96b883ab81d10cd75dcd5d129c15bfb31cd55c7d
Merge pull request #5302 from Geod24/fix-12954

Fix issue 12954 - Deprecated only works with string literals
Comment 3 github-bugzilla 2016-02-12 11:45:43 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dlang.org

https://github.com/D-Programming-Language/dlang.org/commit/ffdb17cde12300f4755ecbd516e7ab6e577c628a
Merge pull request #1229 from Geod24/deprecated-assignexp-pr5302-issue12954

[2.071.0] Document deprecated attribute as accepting AssignExp
Comment 4 github-bugzilla 2016-03-19 20:22:27 UTC
Commit pushed to stable at https://github.com/D-Programming-Language/dlang.org

https://github.com/D-Programming-Language/dlang.org/commit/ffdb17cde12300f4755ecbd516e7ab6e577c628a
Merge pull request #1229 from Geod24/deprecated-assignexp-pr5302-issue12954
Comment 5 github-bugzilla 2017-08-02 08:07:16 UTC
Commit pushed to dmd-cxx at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/58b7f1c1e16c2572799d920d236d4ff52551c2de
Issue 12954 - Deprecated only works with string literals
Comment 6 Mathias LANG 2020-05-18 12:43:34 UTC
*** Issue 16014 has been marked as a duplicate of this issue. ***