Deprecate implicit `int` to `bool` conversion for integer literals

Michael V. Franklin slavo5150 at yahoo.com
Tue Nov 14 23:14:54 UTC 2017


On Tuesday, 14 November 2017 at 13:20:22 UTC, Nick Treleaven 
wrote:

> An very similar problem exists for int and char overloads:
>
> alias foo = (char c) => 1;
> alias foo = (int i) => 4;
>
> enum int e = 7;
> static assert(foo(e) == 4); // fails

Wait a minute!  This doesn't appear to be a casting or overload 
problem.  Can you really overload aliases in D?

I would expect the compiler to throw an error as `foo` is being 
redefined.  Or for `foo` to be replaced by the most recent 
assignment in lexical order.  Am I missing something?

Mike


More information about the Digitalmars-d mailing list