D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7047 - alias error in struct only for dmd1
Summary: alias error in struct only for dmd1
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-01 23:51 UTC by changlon
Modified: 2011-12-09 01:53 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description changlon 2011-12-01 23:51:08 UTC
dmd 1.071 error .

struct Test1 {
    alias typeof(this) This;
    alias This* pThis;
    int number ;
    void Init(){
        static void Callback (void* user_data){
            pThis _this = cast(pThis) user_data;
            auto i = _this.number ;
        }
    }
}

------------
test.d(10): Error: no property 'number' for type 'Test1*'
Comment 1 Don 2011-12-09 01:53:08 UTC
This isn't a regression. It gave exactly the same error back in DMD 1.000.

In fact, it's not even a bug: in D1, 'this' for a struct is a pointer to that struct. As you can see with this code: 

struct Test1 {
    static assert(is(typeof(this) == Test1)); // FAILS !!!
}

In D2, the 'this' pointer is the struct itself.

If you make this change:

-    alias This* pThis;
+    alias This pThis;

your code will compile.