Skip to content

Cache not being triggered correctly when fun arguments start with ... #466

@CeresBarros

Description

@CeresBarros

This issue was initially reported by @ianmseddy in Zulip channel.

I believe the issue is related to the function definition having ... as the first argument.

here's a reprex:

install.packages("Require", repos = "https://predictiveecology.r-universe.dev/")

Require::Require("reproducible", repos = "https://predictiveecology.r-universe.dev/")

myFun <- function(..., arg1, arg2) {
  rnorm(arg1, arg2, ...)
}

myFun2 <- function(arg1, arg2, ...) {
  rnorm(arg1, arg2, ...)
}

out <- myFun(arg1 = 100, arg2 = 2, sd = 10) |>
  Cache()

## doesn't trigger Cache
out <- myFun(arg1 = 100, arg2 = 2, sd = 10) |>
  Cache()


out <- myFun2(arg1 = 100, arg2 = 2, sd = 10) |>
  Cache()

## triggers Cache
out <- myFun2(arg1 = 200, arg2 = 2, sd = 10) |>
  Cache()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions