Skip to content

Commit 7a746b2

Browse files
jmbarboneteunbrand
andauthored
handles empty args in backwards compatible functions (#6711)
* safely handles trailing args for backwards compatibility * adds test * adds news item * Revert "safely handles trailing args for backwards compatibility" This reverts commit 6388981. * allows empty args --------- Co-authored-by: Teun van den Brand <[email protected]>
1 parent da08478 commit 7a746b2

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
legend glyphs (@teunbrand, #6594)
2727
* Fixed regression where `NULL`-aesthetics contributed to plot labels too
2828
insistently. Now they contribute only as fallback labels (@teunbrand, #6616)
29+
* Fixed regression where empty arguments to colour/fill scale caused errors
30+
(@jmbarbone, #6710)
2931
* The `theme(panel.widths, panel.heights)` setting attempts to preserve the
3032
plot's aspect ratio when only one of the two settings is given, and the plot
3133
has a single panel (@teunbrand, #6701).

R/scale-colour.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ check_scale_type <- function(scale, name, aesthetic, scale_is_discrete = FALSE,
285285
scale_backward_compatibility <- function(..., scale, aesthetic, type) {
286286
aesthetic <- standardise_aes_names(aesthetic[1])
287287

288-
args <- list2(...)
288+
# input ... may have trailing args, which then get stuck in the middle #6710
289+
args <- dots_list(..., .ignore_empty = "all")
289290
args$call <- args$call %||% caller_call() %||% current_call()
290291

291292
if (type == "binned") {

tests/testthat/test-scale-colour.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,7 @@ test_that("`name` is directed correctly (#6623)", {
6868
expect_equal(p$name, "foobar")
6969
}
7070
})
71+
72+
test_that("backwards compatibility allows trailing args (#6710)", {
73+
expect_no_error(scale_fill_discrete(breaks = 1:2, direction = -1L, ))
74+
})

0 commit comments

Comments
 (0)