error forward references if scope

vit vit at vit.vit
Sat Mar 12 13:12:25 UTC 2022


Hello,
why this code compile without problems:

```d

struct Query{
     public const SharedPtr!Builder builder;
}

interface Builder{
     void build(ref Query query);
}

struct SharedPtr(T){
     enum touch_T = __traits(hasMember, T, "touch");
     //...
}


void main(){

}

```

but if `ref Query query` is scope then there is error?

```d

struct Query{
     public const SharedPtr!Builder builder;
}

interface Builder{
     void build(scope ref Query query);     //SCOPE
}

struct SharedPtr(T){
     enum touch_T = __traits(hasMember, T, "touch");
     //...
}



void main(){

}
```

```
src/app.d(3,1): Error: no size because of forward references
src/app.d(4,18): Error: template instance 
`app.SharedPtr!(Builder)` error instantiating

```


More information about the Digitalmars-d-learn mailing list