Skip to content

DT() mimics calling [.data.table in that frame - #5176

Merged
mattdowle merged 3 commits into
masterfrom
naming_conflict
Sep 24, 2021
Merged

mattdowle merged 3 commits into
masterfrom
naming_conflict

Conversation

@mattdowle

@mattdowle mattdowle commented Sep 24, 2021 •

Copy link
Copy Markdown
Member

Solves issue 2 within #5129
Added the tests in #5129 (comment) thanks to @Kamgang-B.
The ienv for eval(.massagei(isub), x, ienv) is created with new.env(parent=parent.frame()) so that parent.frame() would need to be something like parent.frame(parent.frame()) when [.data.table had been called from the wrapper DT(). Since there are several other parent.frame() calls inside [.data.table, I went for the approach of making DT() evaluate [.data.table in its parent.frame(); i.e. mimic as if [.data.table had been called directly instead of using the wrapper DT().
Doing that broke test 2212.26-28 but that's good because those were only not changing D due to this scoping. That reassured me that this approach of DT() evaluating [.data.table in calling scope was somehow correct. When a future PR makes DT(:=) return a shallow copy (issue 1 within #5129 and subsequent comments) then those re-copies of mtcars in the tests can be removed and I put a TODO on those copies.
Also, I realized the y= of those tests shouldn't be reusing the input D (which was hiding the fact they shouldn't have been passing in some cases) so that's fixed here by using mtcars in y=.
All in dev before release hence tagged dev.

@mattdowle mattdowle added the dev label Sep 24, 2021
@mattdowle mattdowle added this to the 1.14.3 milestone Sep 24, 2021
@mattdowle mattdowle changed the title DT() mimics calling [.data.table instead DT() mimics calling [.data.table in that frame Sep 24, 2021
@codecov

codecov Bot commented Sep 24, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #5176 (35485a0) into master (8041e48) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head 35485a0 differs from pull request most recent head ef7560a. Consider uploading reports for the commit ef7560a to get more accurate results
Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5176   +/-   ##
=======================================
  Coverage   99.38%   99.38%           
=======================================
  Files          77       77           
  Lines       14507    14510    +3     
=======================================
+ Hits        14418    14421    +3     
  Misses         89       89           
Impacted Files Coverage Δ
R/data.table.R 99.94% <100.00%> (+<0.01%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8041e48...ef7560a. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants