rlang icon indicating copy to clipboard operation
rlang copied to clipboard

`eval_tidy()` with `...` in two-sided formula

Open lionel- opened this issue 3 years ago • 2 comments

rlang::eval_tidy(... ~ 1)
#> Error in rlang::eval_tidy(... ~ 1) : '...' used in an incorrect context

rlang::eval_tidy(1 ~ ...)
Error in rlang::eval_tidy(1 ~ ...) : '...' used in an incorrect context

Causes trouble with data.table: https://github.com/rstudio/shiny/issues/3303 and https://github.com/Rdatatable/data.table/issues/4913

lionel- avatar Mar 01 '21 17:03 lionel-

This is a limitation of R.

tilde <- function(x, y) list(substitute(x), substitute(y))
tilde(1, ...)
#> Error: '...' used in an incorrect context

ignore <- function(x, y) NULL
ignore(1, ...)
#> Error: '...' used in an incorrect context

The argument application routine of the interpreter checks that the calling environment has dots: https://github.com/wch/r-source/blob/2ab3b85b/src/main/eval.c#L3203-L3204 Only SPECIALSXP functions like ~ can be supplied ... without this check.

lionel- avatar Mar 09 '21 14:03 lionel-

One way forward is #1145.

lionel- avatar Apr 01 '21 07:04 lionel-