Fixed nested ':=' reference assignment fails #6789
Open
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.
Fixed nested ':=' reference assignment fails (#6768)
By reference assignments (':=') with functions that modified the data.table by reference e.g. (
foo=function(DT){modify(DT);return(1L)}
,DT[,a:=foo(DT)]
) returned a mallformed data.table due to the modification of the targeted named column index ("a") during the j expression evaluation*Completed TODO: by mattdowle from commits to '2-space indentation #2420' to move allocation logic after jsub evaluation
chmatch and setalloccol calls moved below jsub evaluation which fixed name to column index mapping. Warnings and conditions to terminate early remain before the evaluation. selfrefok warning and following branch were split to accommodate this and to avoid duplicate warnings
*Added tests for jsub expressions that modify DT by-reference
Includes the test that initially demonstrated the bug and an additional test case for future regression testing.
*Added test case for integer vector indexing
Removed pre-jsub-eval numerical lhs to name mapping to prevent issues with duplicate name issues.
Closes #6768