https://issues.dlang.org/show_bug.cgi?id=14363
--- Comment #2 from Shammah Chancellor <[email protected]> --- Your code has a bug? return new B(5); Should be: return new B(); With that, your example compiles and works just fine on SDC. (In reply to Kenji Hara from comment #1) > I'm not sure why SDC accepts the code. > > The following reduced case is correctly rejected by dmd, because ba.foo() > won't work expectedly. Maybe SDC generates wrong code? > > void main() > { > uint x = 7; > > class A > { > auto foo() > { > return x; > } > } > > auto makeB(uint y) > { > class B : A > { > auto bar() > { > return foo() + y; > } > } > > return new B(5); > } > > A a = new A(); > assert(a.foo() == 7); > > auto b = makeB(3); > assert(b.bar() == 10); > > A ba = b; > assert(ba.foo() == 7); > } --
