DIP 1015--Deprecation of Implicit Conversion of Int. & Char. Literals to bool--Formal Assement
Neia Neutuladh
neia at ikeran.org
Tue Nov 13 00:18:13 UTC 2018
On Mon, 12 Nov 2018 14:07:39 -0800, Walter Bright wrote:
> <implicit conversion> <exact> => <implicit
> conversion>
> <implicit conversion> <implicit conversion> => <implicit
> conversion>
One confusion is from value range propagation / constant folding reaching
past the static type information to yield a different result from what
static typing alone would suggest. My intuition was that the compiler
should prefer the declared type of the symbol when it's got a symbol with
a declared type.
Like, A implicitly converts to int, and int doesn't implicitly convert to
short, so an expression of type A shouldn't implicitly convert to short.
And this is *generally* true, but when the compiler can use constant
folding to get a literal value out of the expression, it does things I
don't expect.
And this doesn't happen with structs with alias this, but I can't tell if
that's an oversight or not, and there's no doubt some nuanced explanation
of how things work, and it probably solves some edge cases to have it work
differently...
More information about the Digitalmars-d-announce
mailing list