variable _param_0 cannot be read at compile time

learnfirst1 learnfirst1 at gmail.com
Wed Aug 8 12:57:43 UTC 2018


Why this is a error ?

```
struct S {
         bool v;
         string x;
}

S* add(A...)(ref A a) {
         __gshared s = S(a);
         return &s;
}

void main(){
         auto p = add(true);
}
```

test.d(9): Error: variable _param_0 cannot be read at compile time
test.d(14): Error: template instance `test.add!bool` error 
instantiating
test.d(14): Error: function test.add!bool.add(ref bool _param_0) 
is not callable using argument types (bool)
test.d(14):        cannot pass rvalue argument true of type bool 
to parameter ref bool _param_0



I try pass some into the template to return a __gshared var 
pointer.  the A length is dynamic.





More information about the Digitalmars-d-learn mailing list