[Issue 15055] New: isArray!NonArray doesn't short-circuit an expression
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Sep 13 05:55:28 PDT 2015
https://issues.dlang.org/show_bug.cgi?id=15055
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 at puremagic.com
Reporter: foldenyi.tamas at 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
cast(ubyte)0u
I expect that isArray short circuits the expression before the second half is
evaluated.
I am using DMD64 D Compiler v2.068.0
--
More information about the Digitalmars-d-bugs
mailing list