Cannot take slice of scope static array in @safe code

Dennis dkorpel at gmail.com
Sun Feb 2 13:40:49 UTC 2020


Compiling the following with -dip1000 gives an error.

```
void main() @safe {
     string[1] a0;
     scope int[1] a1;
     scope string[1] a2;

     scope string[] b0 = a0[]; // Fine
     scope int[] b1 = a1[]; // Fine
     scope string[] b2 = a2[]; // Error: cannot take address of 
scope local a2
}
```

Can anyone explain why? I don't see how b2 violates the scope 
constraint of a2.
It might be a compiler bug, but since the int[] case works, I 
could also just be missing something about how `scope` works on 
`string[1]`.


More information about the Digitalmars-d-learn mailing list