hadley / strict

Make R a little bit stricter
236 stars 10 forks source link

Error when using dplyr if list is redefined in a package #37

Open oganm opened 5 years ago

oganm commented 5 years ago

What I am doing is not exactly good practice anyway but I don't really understand why I am getting an error from strict here.

I have a package that creates a structure named list as list = structure(NA, class = 'result') and exports it. I have isolated this and placed it in this package. What it does isn't really important but when this package is loaded, if I try to use dplyr, I get an error

devtools::install_github('oganm/unpack')
library(strict)
library(unpack)
dplyr::filter(data.frame(a = c(1,2,3)), a == 1)
Error in filter_impl(.data, quo) : Evaluation error: [strict]
Multiple definitions found for `list`.
Please pick one:
 * unpack::list
 * base::list
Call `rlang::last_error()` to see a backtrace.

The code above does not try to use list which made me wonder if it can be avoided and why is it happening in the first place.

colman-humphrey commented 5 years ago

I'm sure it's that dplyr::filter is using a list under the hood (getting called in structure_filter I think), which would invoke the error. This would mean that strict is working as intended

oganm commented 5 years ago

But as far as I understand, strict isn't supposed to check the code inside the packages for strictness.