October 31

Hi,

Continuing my work on fixing this bug, it turned out that I was incorrectly modifying the original expression like this:

arr ~= a + b;

// was lowered to:
__tmp = a + b; _d_arrayappendcTX(arr, 1), arr[$ - 1] = tmp;

// but was also changed to:
arr ~= __tmp;

Creating the temporary variable was necessary for situations such as arr ~= arr[$ - 1]. Without it, the lowering would have been _d_arrayappendcTX(arr, 1), arr[$ - 1] = arr[$ - 1]. Note that in the second expression arr[$ - 1] is no longer referring to the same element as in the original expression, but to the newly created element, which is uninitialised.

However, the fix was too hard for the problem it was trying to solve. Simply modifying the IndexExp in the lowering from $ - 1 to $ - 2 was enough and more efficient at the same time. This got rid of the backend bug where the __tmp variable was unrecognised.

However, now this function from DRuntime seems to be visited twice in the glue layer. This makes its vthis to be visited twice as this assert is triggered. I haven't found the source of this error yet.

I also spent some time on convering _d_newarraym{i,}TX to templates and hope I'll be able to fix the final bugs and create a PR for these hooks by the end of this week.

Thanks,
Teodor