Bug 20916 – hard to find where a deprecation comes from

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-06-09T20:44:45Z
Last change time
2020-10-15T05:06:35Z
Keywords
diagnostic, industry, pull
Assigned to
No Owner
Creator
John Colvin

Comments

Comment #0 by john.loughran.colvin — 2020-06-09T20:44:45Z
E.g. Messages like this: /home/john/dlang/dmd-2.091.1/linux/bin64/../../src/phobos/std/range/primitives.d(175,38): Deprecation: alias byKeyValue this is deprecated - Iterate over .byKeyValue instead. with no further information How am I supposed to know where I am doing the wrong thing? Sure, I can use -de, but that has a fatal flaw: compilation stops after the first deprecation. So if I can't fix that one for some reason, I can never get to the rest.
Comment #1 by uplink.coder — 2020-06-10T10:42:22Z
In this case, the deprecation seems actually caused by a template-constraint Which should evaluate the symbol in a speculative context. We could keep track of context I guess ...
Comment #2 by pro.mathias.lang — 2020-10-09T14:22:48Z
Example code: ``` import std.stdio; struct Foo { pure nothrow @nogc @safe: deprecated string toString() const { return "Hello"; } int value; } void main () { Foo f; writeln(f); } ``` Currently this prints: ``` std/format.d(3921): Deprecation: function foo.Foo.toString is deprecated std/format.d(4053): Deprecation: function foo.Foo.toString is deprecated ``` We would like it to print something similar to how template instantiation failures are printed, that is: ``` std/format.d(4053): Deprecation: function foo.Foo.toString is deprecated std/format.d(4430): instantiated from here: formatObject!(LockingTextWriter, Foo, char) std/format.d(1875): instantiated from here: formatValueImpl!(LockingTextWriter, Foo, char) std/format.d(576): instantiated from here: formatValue!(LockingTextWriter, Foo, char) std/stdio.d(1565): instantiated from here: formattedWrite!(LockingTextWriter, char, Foo) std/stdio.d(3927): instantiated from here: write!(Foo, char) foo.d(15): instantiated from here: writeln!(Foo) ```
Comment #3 by dlang-bot — 2020-10-09T17:40:01Z
@Geod24 created dlang/dmd pull request #11839 "Fix 20916 - Print trace for deprecations triggered inside templates" fixing this issue: - Fix 20916 - Print trace for deprecations triggered inside templates https://github.com/dlang/dmd/pull/11839
Comment #4 by b2.temp — 2020-10-11T08:27:59Z
*** Issue 21176 has been marked as a duplicate of this issue. ***
Comment #5 by dlang-bot — 2020-10-15T05:06:35Z
dlang/dmd pull request #11839 "Fix 20916 - Print trace for deprecations triggered inside templates" was merged into master: - 5a86b8dcac2f2e483fbe4ce6264d1238ef6833e6 by Geod24: Fix 20916 - Print trace for deprecations triggered inside templates https://github.com/dlang/dmd/pull/11839