module test.test; class test { int myMember; } typedef test *ptest; void main() { ptest k; k.myMember = 1; } dmd complains: test.d(10): Error: no property 'myMember' for type 'test*' test.d(10): Error: constant (k).myMember is not an lvalue typedef test *ptest; <--- the problem is here. I think it's something related to dmd's strong type mechanism. alias test *ptest; // this would work fine i don't know if i can call this a bug , but at least the compile message should be nicer. Leave to u to decide either this should be a bug or an enhancement.
Because of the 'is a' principle of typedefs, this should work. I call this a bug.
Added to DStress as http://dstress.kuehne.cn/run/t/typedef_23_A.d http://dstress.kuehne.cn/run/t/typedef_23_B.d http://dstress.kuehne.cn/run/t/typedef_23_C.d http://dstress.kuehne.cn/run/t/typedef_23_D.d
alias doesn't seem to be any better. dmd 2.056 64 bit linux, alias JNINativeInterface_* JNIEnv; struct JNINativeInterface_ { int FindClass; } void main(){ JNIEnv* env; auto x = env.FindClass; } compiled results in foo.d(8): Error: no property 'FindClass' for type 'JNINativeInterface_*'
Checked dmd(In reply to comment #3) > alias doesn't seem to be any better. > > dmd 2.056 64 bit linux, > > alias JNINativeInterface_* JNIEnv; > > struct JNINativeInterface_ { > int FindClass; > } > void main(){ > JNIEnv* env; > auto x = env.FindClass; > } > > compiled results in > > foo.d(8): Error: no property 'FindClass' for type 'JNINativeInterface_*' This case is wrong. variable env is of type JNINativeInterface_** so compiler rejects invalid code correctly.
``` alias JNINativeInterface_* JNIEnv; struct JNINativeInterface_ { int FindClass; } void main(){ JNIEnv env; auto x = env.FindClass; } ``` Compiles just fine. Since we don't have Typedef anymore, closing.