Code diagnostics incorrectly flags argument mismatches for functions in a list

Using R Studio version 1.1.453

When the "Check arguments to R function calls" option (Tools > Global Options > Code > Diagnostics) is checked, if a function is created in a list and named after another function, diagnostics will use the function in the list to check subsequent calls.

Example code:

a <- list(
  paste = function(x) paste(x, collapse = ""),
  x     = paste(letters, collapse = "")
)

y <- paste(letters, collapse = "")

Diagnostics flags:

rstudio-diagnostics-bug

In this example, each flag says, "too many arguments in call to 'paste'". Of course, the code runs fine.

I've had (and continue to have) the same issue every once in a while when I redefine function in a package, but before I refresh the session. Looks like this is the case here as well. Code diagnostics probably looks at paste definition that takes only 1 element and then freaks out when it sees paste with multiple arguments.

I'm on Version 1.2.1114 RStudio, so looks like it is "consistent".

2 Likes

Thank you for the bug report! I've reproduced this; would you mind filing this as an issue at https://github.com/rstudio/rstudio/issues?

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.