Debian Codegraph @

gcc/testsuite/gdc.test/compilable/scope_infer_array_assign.d

raw
1 // REQUIRED_ARGS: -preview=dip1000
2
3 // Test that scope inference works even with non POD array assignment
4 // This is tricky because it gets lowered to something like:
5 // (S[] __assigntmp0 = e[]) , _d_arrayassign_l(this.e[], __assigntmp0) , this.e[];
6
7 @safe:
8
9 struct File
10 {
11 void* f;
12 ~this() scope { }
13 }
14
15 struct Vector
16 {
17 File[] e;
18
19 auto assign(File[] e)
20 {
21 this.e[] = e[]; // slice copy
22 }
23 }
24
25 void test(scope File[] arr, Vector v)
26 {
27 v.assign(arr);
28 }