From f6a5b61a91cd9097020ce9679bc4f9b39c7004cd Mon Sep 17 00:00:00 2001 From: Indrajeet Patil Date: Thu, 21 Nov 2024 19:42:42 +0100 Subject: [PATCH] base and internal copies not the same --- DESCRIPTION | 2 +- R/utils.R | 9 +++++++++ R/zzz.R | 2 -- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1c62f687b..2afb4bb1e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,7 @@ BugReports: https://github.com/r-lib/lintr/issues Depends: R (>= 4.0) Imports: - backports (>= 1.5.0), + backports (>= 1.1.7), cli (>= 3.4.0), codetools, digest, diff --git a/R/utils.R b/R/utils.R index a832ebf02..f38941fba 100644 --- a/R/utils.R +++ b/R/utils.R @@ -1,3 +1,12 @@ +`%||%` <- function(x, y) { + is_atomic_and_missing <- is.atomic(x[[1L]]) && is.na(x[[1L]]) + if (is.null(x) || length(x) == 0L || is_atomic_and_missing) { + y + } else { + x + } +} + `%==%` <- function(x, y) { identical(x, y) } diff --git a/R/zzz.R b/R/zzz.R index 5bc2ddb4f..e281353db 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -297,8 +297,6 @@ settings <- new.env(parent = emptyenv()) # R>=4.1.0: ...names backports::import(pkgname, "...names") - # R>=4.4.0: %||% - backports::import(pkgname, "%||%") utils::assignInMyNamespace("default_settings", list( linters = default_linters,