Skip to content

Commit 9f9b21a

Browse files
authored
In qplot, look up layer in ggplot2 package env (#2590)
Fixes #2586. Regression introduced in 4c1964b
1 parent 0c7eda0 commit 9f9b21a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

R/quick-plot.r

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ qplot <- function(x, y, ..., data, facets = NULL, margins = FALSE,
144144
for (g in geom) {
145145
# We reevaluate constants once per geom for historical reasons?
146146
params <- lapply(consts, rlang::eval_tidy)
147-
p <- p + do.call(paste0("geom_", g), params, envir = caller_env)
147+
p <- p + do.call(paste0("geom_", g), params)
148148
}
149149

150150
logv <- function(var) var %in% strsplit(log, "")[[1]]

tests/testthat/test-qplot.r

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,12 @@ test_that("qplot() evaluates constants in the right place", {
2929
})
3030
expect_identical(layer_data(p)$colour, I("red"))
3131
})
32+
33+
test_that("qplot() evaluates layers in package environment", {
34+
geom_line <- function(...) {
35+
stop("!!!")
36+
}
37+
38+
expect_error(p <- qplot(1, 1, geom = "line"), NA)
39+
40+
})

0 commit comments

Comments
 (0)