Provide compat for isTRUE()
Closed this issue · 5 comments
TIL that !isTRUE(structure(TRUE, bla = "blub"))
on older versions of R: ropensci/tic#183 . Do we overwrite isTRUE()
in this case?
isTRUE(structure(TRUE, bla = "blub"))
#> [1] FALSE
Created on 2019-10-01 by the reprex package (v0.3.0)
Session info
sessionInfo()
#> R version 3.3.3 (2017-03-06)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 16.04.6 LTS
#>
#> locale:
#> [1] LC_CTYPE=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
#> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
#> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> loaded via a namespace (and not attached):
#> [1] magrittr_1.5 tools_3.3.3 htmltools_0.3.6 yaml_2.2.0
#> [5] Rcpp_1.0.2 stringi_1.4.3 rmarkdown_1.15 highr_0.8
#> [9] knitr_1.25 stringr_1.4.0 xfun_0.9 digest_0.6.21
#> [13] evaluate_0.14
It's not perfectly clear to me what to do here as R core has not added a function or argument, but just replaced a function with a different one.
Before: identical(x, TRUE)
Now: is.logical(x) && length(x) == 1L && !is.na(x) && x
I assume it is safe here to replace the older implementation with the newer one (at least for packages which are tested to run with recent R versions).
It feels that backporting the behavior is the right thing to do. Can we avoid warnings in R CMD check
or when loading the library?
There should be no warning in R CMD check
. What do you mean?
And there should only be a warning when attaching the package for R versions prior to R-3.5.0. I think these are fine because (a) most people do not attach backports, or they know what they are doing, and (b) these warnings are there for a reason.
I've pushed to master and I'm running a revdep check now.
Uploaded to CRAN.