Skip to content

Commit

Permalink
Attempt to work around R CMD CHECK bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
klmr committed May 1, 2023
1 parent d620fc0 commit 5ddbc72
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions R/format.r
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,22 @@ chr.while =
deparse1(x)
}

# Needs to be defined with `value` as the second argument to silence a spurious
# R CMD check warning in R ≤ 4.1:
# The argument of a replacement function which corresponds to the right hand
# side must be named ‘value’.
`chr.<-` = function (x, value) {
deparse1(x)
}
# The following is required because of a bug in `R CMD CHECK` which erroneously
# flags up a regular declaration of `chr.<-` because it thinks the function is a
# *replacement function*, which requires a `value` argument.
# Adding a dummy `value` argument as a workaround to silence this warning, which
# used to work before R 4.3.0, now fails as well because `R CMD CHECK` rightly
# complains that this function has a different signature than the generic.
# See <https://stackoverflow.com/q/69674485/1968> for more information.
# Alternatively we could export the definitions and add the following:
#
# #' @rawNamespace S3method(chr, "<-", "chr.=")
#
# … however, these are internal functions that should not be exported.

# Use `get` to avoid spurious `R CMD CHECK` warnings about using `.S3method`
# inside a package: in this particular instance *this is what we want!*
wrap_unsafe_function(.BaseNamespaceEnv, '.S3method')('chr', '<-', `chr.=`)

chr.expression = function (x) {
chr(x[[1L]])
Expand Down

0 comments on commit 5ddbc72

Please sign in to comment.