digitalmars.D.bugs - [Issue 15550] New: [Reg 2.070.0-b1] compile error while testing
- via Digitalmars-d-bugs (56/56) Jan 10 2016 https://issues.dlang.org/show_bug.cgi?id=15550
https://issues.dlang.org/show_bug.cgi?id=15550 Issue ID: 15550 Summary: [Reg 2.070.0-b1] compile error while testing template constraint Product: D Version: D2 Hardware: x86_64 OS: All Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: code dawg.eu cat > bug.d << CODE struct Vector(T, int N) { void opDispatch(string, U)(U) { } } struct Matrix(T, int R, int C) { Matrix!(T, R, U._C) opBinary(string op, U)(U) // this constraint causes a compile error (even though the first test already fails) if (is(typeof(U._isMatrix)) && (U._R == C) && (op == "*")) { return Matrix!(T, R, U._C)(); } Vector!(T, R) opBinary(string op)(Vector!(T, C) x) { return Vector!(T, R)(); } enum _R = R; enum _C = C; enum bool _isMatrix = true; } unittest { Matrix!(int, 2, 2) z; auto z2 = z * z; // works static assert(!is(typeof(Vector!(int, 2)._isMatrix))); z * Vector!(int, 2)(); // errors on template constraint } CODE dmd -c -unittest bug ---- math/gfm/math/matrix.d(11): Error: void has no value math/gfm/math/matrix.d(11): Error: incompatible types for ((opDispatch!"_R") == (2)): 'void' and 'int' ---- There is something broken w/ the evaluation of template constraints. if (is(typeof(U._isMatrix)) && (U._R == C) && (op == "*")) In here the IsExp is already false, so the rest shouldn't get evaluated. --
Jan 10 2016