Add test for scope inference with _d_arrayassign_l (#14370)

This commit is contained in:
Dennis 2022-08-16 11:07:09 +01:00 committed by GitHub
parent 479f5aa921
commit 6040e63775
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -0,0 +1,28 @@
// REQUIRED_ARGS: -preview=dip1000
// Test that scope inference works even with non POD array assignment
// This is tricky because it gets lowered to something like:
// (S[] __assigntmp0 = e[]) , _d_arrayassign_l(this.e[], __assigntmp0) , this.e[];
@safe:
struct File
{
void* f;
~this() scope { }
}
struct Vector
{
File[] e;
auto assign(File[] e)
{
this.e[] = e[]; // slice copy
}
}
void test(scope File[] arr, Vector v)
{
v.assign(arr);
}