D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 20916 - hard to find where a deprecation comes from
Summary: hard to find where a deprecation comes from
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: diagnostic, industry, pull
: 21176 (view as issue list)
Depends on:
Blocks:
 
Reported: 2020-06-09 20:44 UTC by John Colvin
Modified: 2020-10-15 05:06 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description John Colvin 2020-06-09 20:44:45 UTC
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 uplink.coder 2020-06-10 10:42:22 UTC
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 Mathias LANG 2020-10-09 14:22:48 UTC
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 Dlang Bot 2020-10-09 17:40:01 UTC
@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 basile-z 2020-10-11 08:27:59 UTC
*** Issue 21176 has been marked as a duplicate of this issue. ***
Comment 5 Dlang Bot 2020-10-15 05:06:35 UTC
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