Skip to content

Commit

Permalink
Merge pull request #693 from nlmixr2/688-feature-request-either-make-…
Browse files Browse the repository at this point in the history
…the-error-message-clearer-or-switch-to-a-warning-with-empty-arguments-in-call-to-rxrename

Warn for empty arguments to rxRename (and anything using `.quoteCallInfoLines()`
  • Loading branch information
mattfidler authored Jun 23, 2024
2 parents d1c62b7 + c805589 commit 98d1a86
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# rxode2 (development version)

## New feaures

- Empty arguments to `rxRename()` give a warning (#688)

# rxode2 2.1.3

## Bug fixes
Expand Down
6 changes: 5 additions & 1 deletion R/piping.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,11 @@
}
}
.quoted <- eval(call("quote", callInfo[[i]]))
if (length(.quoted) == 1) {
if (missing(.quoted)) {
# Capture empty arguments (rxode2#688)
warning("empty argument ignored")
return(NULL)
} else if (length(.quoted) == 1) {
.bracket[i] <- TRUE
assign(".bracket", .bracket, envir=.env)
} else if (identical(.quoted[[1]], quote(`{`)) ||
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-piping-ini.R
Original file line number Diff line number Diff line change
Expand Up @@ -826,3 +826,23 @@ if (!.Call(`_rxode2_isIntel`)) {

})
}

test_that("empty arguments to rxRename() give a warning (#688)", {
mod1 <- function() {
ini({
Kin=1
})
model({
eff <- Kin
})
}

expect_warning(
rxRename(mod1, ),
"empty argument ignored"
)
expect_warning(
rxRename(mod1, foo = eff, ),
"empty argument ignored"
)
})

0 comments on commit 98d1a86

Please sign in to comment.