Skip to content

Commit 1c92f2a

Browse files
Duplicated decorators during an edge case of named and unnamed decorators (#835)
Companion to insightsengineering/teal.modules.clinical#1325 --------- Signed-off-by: Marcin <[email protected]> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 69dc39e commit 1c92f2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

R/utils.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,15 @@ select_decorators <- function(decorators, scope) {
414414
#' @keywords internal
415415
normalize_decorators <- function(decorators) {
416416
if (checkmate::test_list(decorators, "teal_transform_module")) {
417-
if (checkmate::test_names(names(decorators))) {
417+
decorators_names <- names(decorators)[!names(decorators) %in% ""]
418+
# Above is equivalent to decorators_names <- setdiff(names(decorators), "")
419+
# but can return non-unique values. Non-unique values are checked in assert_decorators.
420+
if (length(decorators_names) == 0) {
421+
list(default = decorators)
422+
} else if (length(decorators_names) == length(decorators)) {
418423
lapply(decorators, list)
419424
} else {
420-
list(default = decorators)
425+
stop("All decorators should either be named or unnamed.")
421426
}
422427
} else {
423428
decorators

0 commit comments

Comments
 (0)