Bug 18617 – need __traits(deprecated, expr) to check whether an expression would trigger deprecation
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2018-03-15T09:12:49Z
Last change time
2021-01-03T22:57:17Z
Assigned to
No Owner
Creator
Timothee Cour
Comments
Comment #0 by timothee.cour2 — 2018-03-15T09:12:49Z
we need __traits(deprecated, expr) to check whether an expression would trigger deprecation
this is analog to __traits(compiles, expr) but checks for deprecation instead of whether something compiles.
eg use case (from https://github.com/dlang/phobos/pull/6178#pullrequestreview-104095990)
```
static assert(__traits(deprecated, {int[] a2 = [1, 2].asStatic;}));
instead of simply having a comment:
// NOTE: correctly issues a deprecation
// int[] a2 = [1, 2].asStatic;
```
Comment #1 by timothee.cour2 — 2018-03-15T09:13:35Z
NOTE: IMO std.traits.isDeprecated is not applicable for this use case
Comment #2 by dlang-bot — 2019-09-08T17:50:02Z
@Geod24 created dlang/dmd pull request #10398 "Issue 18617 - Need ability to check if a symbol would trigger a deprecation" mentioning this issue:
- Issue 18617 - Need ability to check if a symbol would trigger a deprecation
... without triggering it !
__traits(isDeprecated, Symbol) currently triggers a deprecation message,
which makes it pretty useless for library writers.
Note that a pitfall is that a library would fail to get a deprecation message,
leading to a failure to remove the access to a symbol if the symbol is hard-coded.
However, the prime usage of __traits(isDeprecated) is for meta-programming,
hence it shouldn't be a problem in practice.
https://github.com/dlang/dmd/pull/10398
Comment #3 by dlang-bot — 2019-09-10T03:34:36Z
dlang/dmd pull request #10398 "Fix Issue 18617 - Need ability to check if a symbol would trigger a deprecation" was merged into master:
- 54574166b70cb0fd03cf5305833c4088923b7976 by Geod24:
Fix Issue 18617 - Need ability to check if a symbol would trigger a deprecation
... without triggering it !
__traits(isDeprecated, Symbol) currently triggers a deprecation message,
which makes it pretty useless for library writers.
Note that a pitfall is that a library would fail to get a deprecation message,
leading to a failure to remove the access to a symbol if the symbol is hard-coded.
However, the prime usage of __traits(isDeprecated) is for meta-programming,
hence it shouldn't be a problem in practice.
https://github.com/dlang/dmd/pull/10398
Comment #4 by dlang-bot — 2021-01-03T22:57:17Z
dlang/dmd pull request #12093 "[dmd-cxx] Backport more recent traits to the C++ port" was merged into dmd-cxx:
- 596401fa8d815314f1d34540c52075df4de7a713 by Geod24:
[dmd-cxx] Fix Issue 18617 - Need ability to check if a symbol would trigger a deprecation without triggering it
https://github.com/dlang/dmd/pull/12093