deprecated enum and to!string warnings

Vladimirs Nordholm v at vladde.net
Mon Nov 19 22:03:10 UTC 2018


On Monday, 19 November 2018 at 21:04:02 UTC, Steven Schveighoffer 
wrote:
> On 11/19/18 2:47 PM, Vladimirs Nordholm 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
>
> Ouch!
>
> I don't know if there's a way to fix this, what I think is 
> happening is there are multiple instantiations of the same 
> template from different places, and each time it's used, it's 
> going to cause a warning.
>
> The reason you see it, even though "baz" isn't used, is likely 
> because of the way to!string works for enums (it probably uses 
> a switch with all the enum values as cases).
>
> -Steve

Yeah, looking at the source code I can see EnumMembers! being 
called, so I'll just have to work around it


More information about the Digitalmars-d mailing list