[Issue 15638] New: no common type for const classes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Feb 2 02:58:08 PST 2016
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 at puremagic.com
Reporter: schuetzm at 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
--
More information about the Digitalmars-d-bugs
mailing list