On Fri, 21 Nov 2014 10:59:13 -0800 Walter Bright via Digitalmars-d <[email protected]> wrote:
> On 11/21/2014 6:03 AM, ketmar via Digitalmars-d wrote: > > On Thu, 20 Nov 2014 13:28:37 -0800 > > Walter Bright via Digitalmars-d <[email protected]> wrote: > > > >> On 11/20/2014 7:52 AM, H. S. Teoh via Digitalmars-d wrote: > >>> What *could* be improved, is the prevention of obvious mistakes in > >>> *mixing* signed and unsigned types. Right now, D allows code like the > >>> following with no warning: > >>> > >>> uint x; > >>> int y; > >>> auto z = x - y; > >>> > >>> BTW, this one is the same in essence as an actual bug that I fixed in > >>> druntime earlier this year, so downplaying it as a mistake people make > >>> 'cos they confound computer math with math math is fallacious. > >> > >> What about: > >> > >> uint x; > >> auto z = x - 1; > >> > >> ? > >> > > here z must be `long`. and for `ulong` compiler must emit error. > > > So, any time an integer literal appears in an unsigned expression, the type > of > the expression becomes signed? nope. only for `auto` expressions.
signature.asc
Description: PGP signature
