Bug? tupleof and const string = ""

John Colvin john.loughran.colvin at gmail.com
Thu Feb 13 08:57:18 PST 2014


On Thursday, 13 February 2014 at 16:52:58 UTC, bearophile wrote:
> 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

Don't you mean const/immutable fields with initialisers don't 
become instance fields? Or is this actually as strange as it 
sounds?


More information about the Digitalmars-d-learn mailing list