mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-04 17:11:44 +03:00

I.e., this fixes #2588. To fix the index of the new array element to be assigned to, I went for decrementing the new length instead of saving the old length directly before the druntime call (i.e., after evaluating the rhs expression due to its potential side effects). The IR seems more intuitive to me this way - load both new length+ptr directly after the druntime call and then decrement the length by 1.
14 lines
181 B
D
14 lines
181 B
D
// RUN: %ldc -run %s
|
|
|
|
int work(ref int[] array)
|
|
{
|
|
array ~= 123;
|
|
return 456;
|
|
}
|
|
|
|
void main()
|
|
{
|
|
int[] array;
|
|
array ~= work(array);
|
|
assert(array == [ 123, 456 ]);
|
|
}
|