Bug? tupleof and const string = ""

bearophile bearophileHUGS at lycos.com
Thu Feb 13 08:52:57 PST 2014


Andre:

> could you have a look whether this is a bug with tupleof?
> In case you have a const string with a default value,
> the attribute is not in the tupleof list.
>
> struct A {
> 	const string a = "abc";
> 	string d;
> }
>
> void main(){
> 	assert(A().tupleof.length == 2); // fails -> length = 1
> }

Tupleeof is working correctly here. Currently const/immutable 
fields don't become struct instance fields. After a transition 
phase this will be changed, and in some months you will see two 
fields there. DMD 2.065 has a warning on this.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list