Type checking on typed enum

Ali Çehreli acehreli at yahoo.com
Sun Sep 16 16:57:55 PDT 2012


On 09/16/2012 04:40 PM, Jonathan M Davis wrote:
 > On Monday, September 17, 2012 01:03:46 ixid wrote:
 >> If I use code like:
 >>
 >> enum ulong VAR = 10;
 >>
 >> I'd have expected this to be type checked when used as a ulong.
 >> Instead it seems to be checked based on its absolute value and is
 >> accepted for a function like:
 >>
 >> void fun(int n) {
 >>       // Do stuff
 >> }

 > That's how it works with integral values in general in D. If the 
compiler can
 > determine that the integral value will fit in the type that you're 
trying to
 > assign it to, then it'll let you do it. There's a term for this, but 
I forget
 > what it is at the moment.

Value range propagation:

   http://www.drdobbs.com/tools/value-range-propagation/229300211

Ali



More information about the Digitalmars-d-learn mailing list