diff --git a/NEWS.md b/NEWS.md index 729783b4..97f94d1d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -18,6 +18,7 @@ * Ensure `rfun()` works with primitive functions (#290) and dots arguments (#291). * Provide implementations of `vctrs::vec_proxy_equal()`, `vctrs::vec_proxy_compare()`, and `vctrs::vec_proxy_order()`. +* Future-proof `cbind()` and `rbind()` for R 4.4 (#304). # posterior 1.4.1 diff --git a/R/rvar-bind.R b/R/rvar-bind.R index bcbef822..55c1a58a 100755 --- a/R/rvar-bind.R +++ b/R/rvar-bind.R @@ -26,16 +26,18 @@ c.rvar <- function(...) { } #' @export -rbind.rvar <- function(...) { - # not sure why deparse.level is not passed here correctly... - deparse.level <- rlang::caller_env()$deparse.level %||% 1 +rbind.rvar <- function(..., deparse.level = 1) { + # deparse.level is not correctly passed here by the default rbind + # implementation in R < 4.4, so we grab it from the calling environment + deparse.level <- rlang::caller_env()$deparse.level %||% deparse.level bind_rvars(list(...), as.list(substitute(list(...))[-1]), deparse.level) } #' @export -cbind.rvar <- function(...) { - # not sure why deparse.level is not passed here correctly... - deparse.level <- rlang::caller_env()$deparse.level %||% 1 +cbind.rvar <- function(..., deparse.level = 1) { + # deparse.level is not correctly passed here by the default cbind + # implementation in R < 4.4, so we grab it from the calling environment + deparse.level <- rlang::caller_env()$deparse.level %||% deparse.level bind_rvars(list(...), as.list(substitute(list(...))[-1]), deparse.level, axis = 2) }