D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 850 - we need (*type).property to refer to property if we use typedef
Summary: we need (*type).property to refer to property if we use typedef
Status: RESOLVED WONTFIX
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-01-14 20:00 UTC by david
Modified: 2018-10-19 04:53 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description david 2007-01-14 20:00:26 UTC
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.
Comment 1 Stewart Gordon 2007-01-15 07:37:38 UTC
Because of the 'is a' principle of typedefs, this should work.  I call this a bug.
Comment 3 Ellery Newcomer 2011-12-08 18:13:43 UTC
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_*'
Comment 4 Lukasz Wrzosek 2012-02-15 08:31:12 UTC
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.
Comment 5 Mathias LANG 2018-10-19 04:53:36 UTC
```
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.