August 10, 2007 Bug with alias const(type)? (DMD 2.003) | ||||
---|---|---|---|---|
| ||||
I'm writing a class that I'm trying to keep compatible with D version 1 but also playing with features of D version 2 (using DMD 1.020 and 2.003 respectively). For the compatibility, I was using a version block to create aliases for const versions of one type for D 2 and just regular non-const versions D 1. The issue I'm having: class A { } class B( TYPE ) { TYPE scalar; TYPE[] array; alias const( TYPE ) CONST_TYPE; alias const( TYPE )[] CONST_ARRAY; const: // This member function compiles fine in DMD 2.003 CONST_ARRAY bar() { return array; } // This member function fails to compile in DMD 2.003 with // the error: cannot implicitly convert expression // (this.scalar) of type const A to constbug.A. CONST_TYPE foo() { return scalar; } // Commenting out the above version and using the following // works as expected. // const(TYPE) foo() // { // return scalar; // } } void main() { B!( A ) test = new B!( A ); } Is it me, or is it rejecting valid code? |
Copyright © 1999-2021 by the D Language Foundation