Bug 7636 – const hole for implicit conversion to base class
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-03-03T16:17:00Z
Last change time
2012-03-04T05:19:41Z
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2012-03-03T16:17:19Z
class Base
{
int _val;
}
class Foo : Base
{
Base base() const { return this; }
}
void main()
{
const(Foo) foo = new const(Foo);
static assert(!__traits(compiles, foo._val = 1));
static assert(!__traits(compiles, foo.base()._val = 1));
foo.base()._val = 1;
assert(foo._val == 0);
}
Also broken for immutable and shared.
--------
This is probably implemented as 'return cast(Base)this;' and
needs to include the right modifiers.
Comment #1 by yebblies — 2012-03-03T20:59:53Z
Is this just 3731?
Comment #2 by code — 2012-03-04T05:19:41Z
*** This issue has been marked as a duplicate of issue 3731 ***