Skip to content

Commit 5e939fb

Browse files
authored
Fix error when constructor formals are empty (RConsortium#475)
* accept `modify_list(NULL, list())`
1 parent b5cf389 commit 5e939fb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

R/utils.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ modify_list <- function (x, new_vals) {
138138
nms <- names2(new_vals)
139139
if (!all(nzchar(nms)))
140140
stop("all elements in `new_vals` must be named")
141+
if (is.null(x))
142+
x <- list()
141143
x[nms] <- new_vals
142144
}
143145

@@ -146,7 +148,7 @@ modify_list <- function (x, new_vals) {
146148

147149
deparse_trunc <- function(x, width, collapse = "\n") {
148150
x <- deparse1(x, collapse)
149-
if (nchar(x)> width)
151+
if (nchar(x) > width)
150152
x <- sprintf("%s....", substr(x, 0, width-4))
151153
x
152154
}

0 commit comments

Comments
 (0)