diff --git a/R/quasi-label.R b/R/quasi-label.R index 0390da8b4..529634a23 100644 --- a/R/quasi-label.R +++ b/R/quasi-label.R @@ -59,10 +59,11 @@ quasi_label <- function(quo, label = NULL, arg = NULL) { } labelled_value <- function(value, label) { - list( - val = value, - lab = label - ) + if (missing(value)) { + list(val = missing_arg(), lab = label) + } else { + list(val = value, lab = label) + } } quasi_capture <- function(.quo, .label, .capture, ...) { diff --git a/tests/testthat/_snaps/quasi-label.md b/tests/testthat/_snaps/quasi-label.md index 853a3b923..224e042ba 100644 --- a/tests/testthat/_snaps/quasi-label.md +++ b/tests/testthat/_snaps/quasi-label.md @@ -1,3 +1,14 @@ +# missing arguments are propagated + + Code + expect_null(x$missing) + Condition + Error: + ! Expected `x$missing` to be NULL. + Differences: + `actual` is absent + `expected` is NULL + # produces useful summaries for long calls Code diff --git a/tests/testthat/test-quasi-label.R b/tests/testthat/test-quasi-label.R index 501013be9..24a006279 100644 --- a/tests/testthat/test-quasi-label.R +++ b/tests/testthat/test-quasi-label.R @@ -10,6 +10,10 @@ test_that("symbols are quoted", { expect_equal(expr_label(quote(a)), "`a`") }) +test_that("missing arguments are propagated", { + x <- list(missing = missing_arg()) + expect_snapshot_failure(expect_null(x$missing)) +}) test_that("is_call_infix() handles complex calls (#1472)", { expect_false(is_call_infix(quote(