deprecated enum and to!string warnings

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Nov 19 21:03:31 UTC 2018


On Monday, November 19, 2018 12:47:44 PM MST Vladimirs Nordholm via 
Digitalmars-d wrote:
> The following code produces 28 deprecation warnings at build time:
>
>      import std.conv : to;
>
>      enum Foo {
>          bar,
>          deprecated baz
>      }
>
>      void main() {
>          to!string(Foo.bar);
>      }
>
> Why is that?
>
> https://run.dlang.io/is/AdUscN

You're going to get a deprecation message every time baz is used, and in
order for to!string to do its thing, it uses it in a bunch of places
internally. Glancing at the output there, it does look like the messages are
doubled up for some reason, with each line being listed twice, which is a
bit odd, and I'd have to do some digging to see why that is happening, but
the fact that you're getting multiple deprecation messages is not surprising
considering that you're compiling a templated function that is using a
deprecated symbol. If you were calling a non-templated function, then you
would just get a deprecation message at the call point, but you're calling a
templated function that's then doing type introspection on the deprecated
symbol, so it refers to it a lot internally.

Also, FYI, please ask questions about learning D in the D.Learn newsgroup /
forum, not the general newsgroup / forum. This is for general discussion on
D, not for asking questions on how to use D or how it works.

- Jonathan M Davis





More information about the Digitalmars-d mailing list