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
Comment #2 by github-bugzilla — 2016-02-10T04:46:23Z
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 by github-bugzilla — 2016-02-12T11:45:43Z
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 by github-bugzilla — 2016-03-19T20:22:27Z
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 by github-bugzilla — 2017-08-02T08:07:16Z
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 by pro.mathias.lang — 2020-05-18T12:43:34Z
*** Issue 16014 has been marked as a duplicate of this issue. ***