www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - type combination of qualified dynamic array / pointer types inconsistent

 From TDPL p60 (type combination algorithm):

"1. If a and b have the same type, T is that type.
  2. else if a and b are integrals [...]
  3. else if one is an integral and [...]
  4. else if both have floating point type [...]
  5. else if both have a common supertype (eg., base class), T is that 
type. [...]
  6. else try implicitly converting a to b's type and b to a's type; if 
exactly one of these conversions succeeds, T is the type of the 
successful conversion target.
  7. else [...]"

const(int*) x;
const(immutable(int)*) y;

static assert(is(typeof(y) : typeof(x)) && !is(typeof(x) : typeof(y))); 
// passes.
static assert(is(typeof(1?x:y) == typeof(x))); // fails.

//(typeof(1?x:y) is computed as const(int)*)

const(int[]) z;
const(immutable(int)[]) w;

static assert(is(typeof(w) : typeof(z)) && !is(typeof(z) : typeof(w))); 
// passes.
static assert(is(typeof(1?z:w) == typeof(z))); // passes.

//(typeof(1?z:w) is computed as const(int[]))

To be consistent, both type combinations should agree on resulting in 
either a head-mutable type or a head-const type.

What is the design here?
Nov 12 2011