Unexpected Output from delete from array #700
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Unexpected Output from delete from array BUG
Delete from array doesn't work correctly for non-flat arrays(>=2-d array) if in a loop. I have attached the behavior below.
cv.mp4
Delete from array works fine for the first iteration, but after the first iteration, the values in the input array somehow get deleted which also makes the deleted and output array reflect the same. In the second iteration when ResizeDimension is called on deletedArray(line 1316) and arrayOut(line 1323), and getInit happens for them, it basically initializes the input array's values as well which should not have happened. We found out this happens because deletedArray and arrayOut don't get copied correctly(from the copy subarray function) and the values are still related to the input array. So when getInit happens for the deleted and output array and their values are getting initialized and as they still point to the input array, values of the input array get changed.
In this PR, we have fixed the issue by changing how the non-flat array gets copied from the CopySubarray function. The changes are done for non-flat type arrays and for flat type it's still the same. I have used what we have for elementType->CopyData so that a proper copy(deep copy) happens.
I have tested the changes manually with different cases and also have added a test. The reason I didn't add it in ArrayDelete.via was as I have added a loop as well just to be sure. Attached the via below
CI Build in my branch - build (Lint is failing because of 4 dead links. I tried searching why is it happening but didn't find anything significant)
Run the squad tests - pipeline
@shivaprasad-basavaraj