fix auto-print detection on R 3.4/3.5 where sys.calls() returns a promise#7727
fix auto-print detection on R 3.4/3.5 where sys.calls() returns a promise#7727skitsy24 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7727 +/- ##
=======================================
Coverage 99.04% 99.04%
=======================================
Files 87 87
Lines 17123 17043 -80
=======================================
- Hits 16959 16880 -79
+ Misses 164 163 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bringing branch in sync with main repo
| } else if (typeof(SYS[[1L]][[1L]]) == "promise") { | ||
| # in R 3.4 and R 3.5, auto-print uses a promise to reference base::print due to lazy loading | ||
| # safely evaluate promise to get the actual function | ||
| evaluated = tryCatch(eval(SYS[[1L]][[1L]]), error = function(e) NULL) | ||
| if (identical(evaluated, print)) { | ||
| is_print_call = TRUE | ||
| } | ||
| } |
There was a problem hiding this comment.
This disappeared in R-3.6.0, right? Let's wrap this branch in # nocov start ... # nocov end and add a # TODO(R>=3.6) comment to remove it once we raise the minimal supported R version.
9318753 to
194ef2b
Compare
aitap
left a comment
There was a problem hiding this comment.
The fix is good, tested manually on R-3.5.0. Could you please fix the whitespace issues and add a NEWS.md item describing the bug fix?
|
Changes made, and added item to NEWS |
| * using log directory ‘/home/skit/data.table/..Rcheck’ | ||
| * using R version 3.5.0 (2018-04-23) | ||
| * using platform: x86_64-pc-linux-gnu (64-bit) | ||
| * using session charset: UTF-8 | ||
| * using option ‘--no-manual’ | ||
| * checking for file ‘./DESCRIPTION’ ... ERROR | ||
| Required fields missing or empty: | ||
| ‘Author’ ‘Maintainer’ | ||
| * DONE | ||
| Status: 1 ERROR |
There was a problem hiding this comment.
pls dont commit Rcheck files
ben-schwen
left a comment
There was a problem hiding this comment.
The diff somehow got blown off. Seems like a mislucked merge
|
You seem to have ended up with git checkout fix7099
git remote add upstream https://github.com/rdatatable/data.table
git fetch upstream
git rebase -i upstream/master
# drop 9d7b4f4f Revert workflow file change
git push -fNormally we only merge |
|
Looking at it, I did merge master then rebased my branch, sorry! It should now ONLY have the changes I made, again sorry! |
Closes #7099.
On R 3.4 and 3.5, the top-level call captured via sys.calls() during auto-print is not a direct reference to base::print, but a promise object that evaluates to it. As a result, the existing check:
identical(SYS[[1L]][[1L]], print)
fails, and print.data.table() incorrectly treats auto-print as an explicit print() call. This leads to unintended output in cases where printing should be suppressed (e.g., after := assignments).
Thanks to @aitap for identifying the root cause.
My fix adds a check on whether print() is wrapped in a "promise" to differentiate between the older R versions. If it is a promise, the promise is evaluated, and then checked against print.