r-lib / rlang

Low-level API for programming with R
https://rlang.r-lib.org
Other
491 stars 131 forks source link

Closes #1655 add back-compatibility to `expr_label()` for incoming `is.atomic(NULL)` change in R version 4.4 #1656

Closed zdz2101 closed 9 months ago

zdz2101 commented 9 months ago

Closes https://github.com/r-lib/rlang/issues/1655

Copy of issue below:

One of the main "significant user-visible changes" for the upcoming R release, v4.4, is that:

expr_label(NULL) under R <4.4 would return "NULL" expr_label(NULL) under R 4.4 would return "`NULL`"

Although expr_label() is already under lifecycle label questioning, this may have minor unintended consequences

expr_label <- function(expr) {
  if (is.character(expr)) {
    encodeString(expr, quote = '"')
  } else if (is.atomic(expr)) { # should this be replaced with (is.null(expr) || is.atomic(expr))  ?
    format(expr)
  } else if (is.name(expr)) {
    paste0("`", as.character(expr), "`")
  } else {
    chr <- deparse_one(expr)
    paste0("`", chr, "`")
  }
}
lionel- commented 9 months ago

Thanks!