r-lib / rlang

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

`expr_label()` has a reference to `is.atomic()` that will be affected by incoming R version 4.4 #1655

Closed zdz2101 closed 1 year ago

zdz2101 commented 1 year ago

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, "`")
  }
}