Skip to content

Commit 81fb4bc

Browse files
committed
feat(as_slide_computation): abort nonempty ... with formula
instead of ignoring them.
1 parent 2791f01 commit 81fb4bc

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

R/utils.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ as_slide_computation <- function(f, ...) {
272272
epiprocess__f = f,
273273
call = call)
274274
}
275+
if (rlang::dots_n(...) > 0L) {
276+
Abort("No arguments can be passed via `...` when `f` is a formula, or there are unrecognized/misspelled parameter names.",
277+
class = "epiprocess__as_slide_computation__formula_with_dots",
278+
epiprocess__f = f,
279+
epiprocess__enquos_dots = enquos(...))
280+
}
275281

276282
env <- f_env(f)
277283
if (!is_environment(env)) {

tests/testthat/test-utils.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,10 @@ test_that("as_slide_computation raises errors as expected", {
207207
expect_error(as_slide_computation(y ~ ..1),
208208
class="epiprocess__as_slide_computation__formula_is_twosided")
209209

210+
# Formulas can't be paired with ...
211+
expect_error(as_slide_computation(~ ..1, method = "fn"),
212+
class="epiprocess__as_slide_computation__formula_with_dots")
213+
210214
# `f_env` must be an environment
211215
formula_without_env <- stats::as.formula(~ ..1)
212216
rlang::f_env(formula_without_env) <- 5

0 commit comments

Comments
 (0)