import std.stdio;
class A { int val; }
class B : A { this() { val = 3; } }
class C : A { this() { val = 4; } }
void main()
{
const B b;
const C c;
writeln(true ? b : c);
}
Error: incompatible types for ((b) : (c)): 'const(B)' and 'const(C)'
AFAICS there is no reason why this should be disallowed, considering that the following works:
const A a1 = b;
const A a2 = c;
The common type should be `const(A)`.
This seems to be an unintended side-effect of this PR:
https://github.com/D-Programming-Language/dmd/pull/125
Discovered by SimonN:
http://forum.dlang.org/post/[email protected]
Comment #1 by hsteoh — 2016-02-12T02:00:04Z
Confirmed with git that PR #125 causes this problem.
Comment #2 by hsteoh — 2016-02-12T02:01:20Z
(Or exposed a latent bug in the common type code?)