Skip to content

Commit 81be15e

Browse files
Merge branch 'main' into backport-performance
2 parents e3712a1 + 3fd1bd6 commit 81be15e

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

R/object_overwrite_linter.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ object_overwrite_linter <- function(
7070
stringsAsFactors = FALSE
7171
)
7272

73+
# Take the first among duplicate names, e.g. 'plot' resolves to base::plot, not graphics::plot
74+
pkg_exports <- pkg_exports[!duplicated(pkg_exports$name), ]
75+
7376
# test that the symbol doesn't match an argument name in the function
7477
# NB: data.table := has parse token LEFT_ASSIGN as well
7578
xpath <- glue("

tests/testthat/test-object_overwrite_linter.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ test_that("object_overwrite_linter blocks simple disallowed usages", {
2929
linter
3030
)
3131

32+
# base and graphics both export 'plot' (in recent R); ensure this is no issue
33+
plot_pkg <- environmentName(environment(plot))
34+
expect_lint(
35+
"function() plot <- 1",
36+
rex::rex("'plot' is an exported object from package '", plot_pkg, "'."),
37+
linter
38+
)
39+
3240
# not just the top level of the function
3341
expect_lint(
3442
trim_some("

0 commit comments

Comments
 (0)