digitalmars.D.bugs - [Issue 15638] New: no common type for const classes
- via Digitalmars-d-bugs (35/35) Feb 02 2016 https://issues.dlang.org/show_bug.cgi?id=15638
https://issues.dlang.org/show_bug.cgi?id=15638 Issue ID: 15638 Summary: no common type for const classes Product: D Version: D2 Hardware: x86_64 URL: https://github.com/D-Programming-Language/dmd/pull/125 OS: Linux Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: schuetzm gmx.net 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/vgwdoqmdzxyegnautwgv forum.dlang.org --
Feb 02 2016