www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15055] New: isArray!NonArray doesn't short-circuit an


          Issue ID: 15055
           Summary: isArray!NonArray doesn't short-circuit an expression
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: foldenyi.tamas gmail.com

I expect the following code run without an error:

template sameUnqualArrays(A, B) {
  enum bool sameUnqualArrays = isArray!A && isArray!B &&
      is(Unqual!(ForeachType!A) == Unqual!(ForeachType!B));

unittest {
  static assert(sameUnqualArrays!(ubyte[], immutable(ubyte[])));
  static assert(!sameUnqualArrays!(ubyte[], immutable(byte[])));
  static assert(!sameUnqualArrays!(ubyte[], ubyte));

But the last assert gives an error:
/usr/include/dmd/phobos/std/traits.d(6062,9): Error: invalid foreach aggregate

I expect that isArray short circuits the expression before the second half is

I am using DMD64 D Compiler v2.068.0

Sep 13 2015