Deprecate implicit `int` to `bool` conversion for integer literals
Michael V. Franklin
slavo5150 at yahoo.com
Tue Nov 14 14:01:56 UTC 2017
On Tuesday, 14 November 2017 at 13:43:32 UTC, Michael V. Franklin
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
>>
>> Thanks. Addressing this should be part of the DIP as well. --
>
> It doesn't appear to be related to the implicit conversion of
> integer literals to bool. While Andrei's example is fixed by
> by deprecating implicit conversion of integral literals to bool
> (at least using this implementation:
> https://github.com/dlang/dmd/pull/7310), Nick's example isn't.
Well, of course it's not related; it's a char not a bool. But
there does seem to be some systematic problems in D's implicit
conversion rules. I'll have to investigate this and perhaps I
can address them both in one DIP.
Mike
More information about the Digitalmars-d
mailing list