mirror of
https://github.com/dlang/dmd.git
synced 2025-04-27 05:30:13 +03:00
Add test for scope inference with _d_arrayassign_l
(#14370)
This commit is contained in:
parent
479f5aa921
commit
6040e63775
1 changed files with 28 additions and 0 deletions
28
compiler/test/compilable/scope_infer_array_assign.d
Normal file
28
compiler/test/compilable/scope_infer_array_assign.d
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue