Bug description
Documenting multiple arguments with a shared description (i.e., using the form @param x2,x3 second and third argument) leads to an error when inheriting filtered arguments of that function, even if the inherited arguments are not in this 'special' format, e.g., inheriting x1 from toy_fun_parent(), see below).
Setup for reprex
library(usethis)
path <- withr::local_tempdir(pattern = "inheritargs", clean = TRUE)
desc <- desc::description$new("!new")
desc$write(file = fs::path(path, "DESCRIPTION"))
local_project(path)
Creating functions
Create toy_fun_parent() in which arguments x2 and x3 share a single description:
Paste the following code in the created file:
#' Toy parent function
#' @param x1 first argument
#' @param x2,x3 second and third argument
#' @param x4 fourth argument
#' @returns NULL
#' @export
toy_fun_parent <- function(x1, x2, x3, x4) {
NULL
}
Then create toy_fun_child() that inherits argument x1 from toy_fun_parent():
Paste the following code in the created file
#' Toy child function
#' @inheritParams toy_fun_parent x1
#' @returns NULL
#' @export
toy_fun_child <- function(x1) {
NULL
}
Triggering the bug
After saving the created function files, roxygenising leads to an error:
# Code taken from `devtools::document()` because that is how I encountered the error
roxygen2::roxygenise(devtools::as.package(".")$path, roclets = NULL)
# Error in vapply(.x, .f, .mold, ..., USE.NAMES = FALSE) :
# values must be length 1,
# but FUN(X[[2]]) result is length 2
That error apparently occurs because .rlang_purrr_map_mold() (source code) produces a length-two result (i.e., one for x2 and one for x3) whereas vapply() expects a length-one result.
traceback()
10: vapply(.x, .f, .mold, ..., USE.NAMES = FALSE)
9: .rlang_purrr_map_mold(.x, .f, character(1), ...)
8: map_chr(inherited_params, "[[", "name")
7: fun(topic, self, ...)
6: topics$topo_apply(inherits("params"), inherit_params)
5: topics_process_inherit(topics, env)
4: roclet_process.roclet_rd(X[[i]], ...)
3: FUN(X[[i]], ...)
2: lapply(roclets, roclet_process, blocks = blocks, env = env, base_path = base_path)
1: roxygen2::roxygenise(devtools::as.package(".")$path, roclets = NULL)
Unfortunately I do not understand the syntax of inherited_params or topo_apply(), so I was not able to propose a fix.
Bug description
Documenting multiple arguments with a shared description (i.e., using the form
@param x2,x3 second and third argument) leads to an error when inheriting filtered arguments of that function, even if the inherited arguments are not in this 'special' format, e.g., inheritingx1fromtoy_fun_parent(), see below).Setup for reprex
Creating functions
Create
toy_fun_parent()in which argumentsx2andx3share a single description:Paste the following code in the created file:
Then create
toy_fun_child()that inherits argumentx1fromtoy_fun_parent():Paste the following code in the created file
Triggering the bug
After saving the created function files, roxygenising leads to an error:
That error apparently occurs because
.rlang_purrr_map_mold()(source code) produces a length-two result (i.e., one forx2and one forx3) whereasvapply()expects a length-one result.Unfortunately I do not understand the syntax of
inherited_paramsortopo_apply(), so I was not able to propose a fix.