Bug 20307 – Difference for `deprecated alias a = b` vs. `deprecated alias b a`
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2019-10-18T18:31:16Z
Last change time
2023-04-18T09:08:07Z
Assigned to
No Owner
Creator
kinke
Comments
Comment #0 by kinke — 2019-10-18T18:31:16Z
Compile this with `-w` (https://run.dlang.io/is/B5ifPu):
```
deprecated ("bla") void foo();
deprecated alias foo f; // 2 deprecation msges
deprecated alias g = foo; // no deprecation msg
deprecated ("bla") alias foo h; // no deprecation msg either
```
Output:
```
onlineapp.d(3): Deprecation: function `onlineapp.foo` is deprecated - bla
onlineapp.d(3): Deprecation: function `onlineapp.foo` is deprecated - bla
```
This is actually adapted from druntime (core.sys.windows.odbcinst).
1) Why is there a difference between `deprecated alias foo f` and `deprecated alias f = foo`?
2) Why does adding a msg make a difference?
3) Why is the deprecation msg printed twice for the same trivial alias declaration?
Comment #1 by pro.mathias.lang — 2020-02-21T09:04:04Z
Note that the correct behavior here would be to output no message.
The reasoning is that those alias are deprecated, and *declaring* deprecated symbols does not trigger a message, only using them.
So the behavior of the old alias syntax is actually what needs to be fixed.
1) I assume they are parsed differently (since the new alias syntax can be a template declaration)
2) I don't see a difference, both `g` and `h` are not outputting a message, right ?
3) That's a bug
Comment #2 by pro.mathias.lang — 2020-02-21T09:07:11Z
Re 3: I misread the example as using the new alias syntax for `h` but it's using the old one.
Comment #3 by razvan.nitu1305 — 2023-04-18T09:08:07Z
This seems to have been fixed. I cannot reproduce the deprecation messages. I get a graceful compilation. Closing as WORKSFORME. Please reopen if I am missing something.