www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Error: non-shared method Node.~this is not callable using a shared

reply ChangLong <changlon gmail.com> writes:
This code is not working.
-----------------------
shared struct Stack {
         Node n = void ;
}
struct Node {
         ~this() {}
}
-----------------------
Error: non-shared method test.Node.~this is not callable using a 
shared object

Is this a bug ?  Node.~this is not called from Stack.
Jan 06
parent Binghoo Dang <dangbinghoo gmail.com> writes:
On Saturday, 6 January 2018 at 11:23:13 UTC, ChangLong wrote:
 This code is not working.
 -----------------------
 shared struct Stack {
         Node n = void ;
 }
 struct Node {
         ~this() {}
 }
 -----------------------
 Error: non-shared method test.Node.~this is not callable using 
 a shared object

 Is this a bug ?  Node.~this is not called from Stack.
take a look at http://ddili.org/ders/d.en/struct.html constructor and destructor for struct must be static.
Jan 06