Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defusing numbered dots #1137

Closed
lionel- opened this issue Mar 23, 2021 · 0 comments · Fixed by #1138
Closed

Defusing numbered dots #1137

lionel- opened this issue Mar 23, 2021 · 0 comments · Fixed by #1138
Labels

Comments

@lionel-
Copy link
Member

lionel- commented Mar 23, 2021

This should capture foo:

f <- function(...) enquo(..1)
f(foo)
#> Error in (function (arg)  : object '..1' not found

When match.call() matches dots, it creates numbered dots like ..1 or ..2. Currently enquo() and enquos() don't handle these. This makes it difficult to use call-matching idioms which are sometimes useful (I think call-matching would be helpful to solve tidyverse/dplyr#5815).

defuser <- function(...) enquos(...)


### Expected output

wrapper <- function(...) {
  foo <- 1
  defuser(..., y = foo)
}
local({
  bar <- 10
  wrapper(x = bar)
})
#> <list_of<quosure>>
#>
#> $x
#> <quosure>
#> expr: ^bar
#> env:  0x7fa13f27b040
#>
#> $y
#> <quosure>
#> expr: ^foo
#> env:  0x7fa13f27add8


### Problematic output

wrapper2 <- function(...) {
  foo <- 1
  eval(match.call(
    defuser,
    quote(defuser(..., y = foo)),
    envir = environment()
  ))
}
local({
  bar <- 10
  wrapper2(x = bar)
})
#> <list_of<quosure>>
#>
#> $x
#> <quosure>
#> expr: ^..1
#> env:  0x7fa1488cb438
#>
#> $y
#> <quosure>
#> expr: ^foo
#> env:  0x7fa1488cb438
lionel- added a commit that referenced this issue Mar 23, 2021
Closes #1137
Step towards #5815
lionel- added a commit that referenced this issue Mar 23, 2021
Closes #1137
Step towards #5815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant