diff --git a/R/arrange.R b/R/arrange.R index 30aff78bbd..ae43ab49f3 100644 --- a/R/arrange.R +++ b/R/arrange.R @@ -121,7 +121,9 @@ arrange_rows <- function(.data, dots) { if (inherits(cnd, "dplyr:::mutate_error")) { # reverse the name mangling - bullets <- gsub("^^--arrange_quosure_", "..", cnd$bullets, fixed = TRUE) + bullets <- cnd$bullets + names(bullets)[1] <- "x" + bullets <- gsub("^^--arrange_quosure_", "..", bullets, fixed = TRUE) } else { bullets <- c(x = conditionMessage(cnd)) } diff --git a/src/mask.cpp b/src/mask.cpp index db4ed696a0..e3e76f5882 100644 --- a/src/mask.cpp +++ b/src/mask.cpp @@ -66,22 +66,6 @@ SEXP dplyr_mask_add(SEXP env_private, SEXP s_name, SEXP chunks) { return R_NilValue; } -// no C-api for rm() so callback to R :shrug: -SEXP get_rm_call() { - SEXP rm_call = PROTECT(Rf_lang3(dplyr::symbols::rm, R_NilValue, R_NilValue)); - SET_TAG(CDDR(rm_call), dplyr::symbols::envir); - R_PreserveObject(rm_call); - UNPROTECT(1); - return rm_call; -} - -void rm(SEXP name, SEXP env) { - static SEXP rm_call = get_rm_call(); - SETCADR(rm_call, name); - SETCADDR(rm_call, env); - Rf_eval(rm_call, R_BaseEnv); -} - SEXP dplyr_mask_remove(SEXP env_private, SEXP s_name) { SEXP name = STRING_ELT(s_name, 0); @@ -102,10 +86,10 @@ SEXP dplyr_mask_remove(SEXP env_private, SEXP s_name) { SEXP chops = PROTECT(Rf_findVarInFrame(env_private, dplyr::symbols::chops)); SEXP sym_name = PROTECT(rlang::str_as_symbol(name)); - rm(sym_name, chops); + rlang::env_unbind(chops, sym_name); SEXP mask = PROTECT(Rf_findVarInFrame(env_private, dplyr::symbols::mask)); - rm(sym_name, ENCLOS(mask)); + rlang::env_unbind(ENCLOS(mask), sym_name); UNPROTECT(4); } diff --git a/tests/testthat/_snaps/across.md b/tests/testthat/_snaps/across.md index 811b7631a7..2411fb0d59 100644 --- a/tests/testthat/_snaps/across.md +++ b/tests/testthat/_snaps/across.md @@ -25,7 +25,7 @@ # if_any() and if_all() aborts when predicate mistakingly used in .cols= (#5732) Code - (expect_error(filter(df, if_any(~.x > 5)))) + (expect_error(filter(df, if_any(~ .x > 5)))) Output Problem with `filter()` input `..1`. @@ -35,7 +35,7 @@ i The first argument `.cols` selects a set of columns. i The second argument `.fns` operates on each selected columns. Code - (expect_error(filter(df, if_all(~.x > 5)))) + (expect_error(filter(df, if_all(~ .x > 5)))) Output Problem with `filter()` input `..1`. @@ -45,7 +45,7 @@ i The first argument `.cols` selects a set of columns. i The second argument `.fns` operates on each selected columns. Code - (expect_error(filter(df, !if_any(~.x > 5)))) + (expect_error(filter(df, !if_any(~ .x > 5)))) Output Problem with `filter()` input `..1`. @@ -55,7 +55,7 @@ i The first argument `.cols` selects a set of columns. i The second argument `.fns` operates on each selected columns. Code - (expect_error(filter(df, !if_all(~.x > 5)))) + (expect_error(filter(df, !if_all(~ .x > 5)))) Output Problem with `filter()` input `..1`. diff --git a/tests/testthat/_snaps/arrange.md b/tests/testthat/_snaps/arrange.md index 2387f935f5..a3ee8e6d0f 100644 --- a/tests/testthat/_snaps/arrange.md +++ b/tests/testthat/_snaps/arrange.md @@ -12,7 +12,7 @@ tibble(x = 1) %>% arrange(y) Error arrange() failed at implicit mutate() step. - * Problem with `mutate()` column `..1`. + x Problem with `mutate()` column `..1`. i `..1 = y`. x object 'y' not found @@ -22,7 +22,7 @@ tibble(x = 1) %>% arrange(rep(x, 2)) Error arrange() failed at implicit mutate() step. - * Problem with `mutate()` column `..1`. + x Problem with `mutate()` column `..1`. i `..1 = rep(x, 2)`. i `..1` must be size 1, not 2. diff --git a/tests/testthat/_snaps/colwise-filter.md b/tests/testthat/_snaps/colwise-filter.md index 4b592542f0..e3cb54f06e 100644 --- a/tests/testthat/_snaps/colwise-filter.md +++ b/tests/testthat/_snaps/colwise-filter.md @@ -8,7 +8,7 @@ --- Code - filter_all(mtcars, list(~. > 0)) + filter_all(mtcars, list(~ . > 0)) Error `.vars_predicate` must be a function or a call to `all_vars()` or `any_vars()`, not a list. diff --git a/tests/testthat/_snaps/deprec-funs.md b/tests/testthat/_snaps/deprec-funs.md index f4e0bbba1d..92b38e3709 100644 --- a/tests/testthat/_snaps/deprec-funs.md +++ b/tests/testthat/_snaps/deprec-funs.md @@ -32,7 +32,7 @@ --- Code - funs(~mp[.]) + funs(~ mp[.]) Error `~mp[.]` must be a function name (quoted or unquoted) or an unquoted call, not `~`. diff --git a/tests/testthat/_snaps/filter.md b/tests/testthat/_snaps/filter.md index 81f64c921f..9f4009466d 100644 --- a/tests/testthat/_snaps/filter.md +++ b/tests/testthat/_snaps/filter.md @@ -173,7 +173,7 @@ --- Code - data.frame(x = 1, y = 1) %>% filter(across(everything(), ~.x > 0)) + data.frame(x = 1, y = 1) %>% filter(across(everything(), ~ .x > 0)) Output x y 1 1 1 diff --git a/tests/testthat/_snaps/group-by.md b/tests/testthat/_snaps/group-by.md index 396c0db8e1..99beb2c389 100644 --- a/tests/testthat/_snaps/group-by.md +++ b/tests/testthat/_snaps/group-by.md @@ -26,12 +26,10 @@ df %>% ungroup(x) Error `...` is not empty. - - We detected these problematic arguments: + i These dots only exist to allow future extensions and should be empty. + x We detected these problematic arguments: * `..1` - - These dots only exist to allow future extensions and should be empty. - Did you misspecify an argument? + i Did you misspecify an argument? --- diff --git a/tests/testthat/_snaps/group_map.md b/tests/testthat/_snaps/group_map.md index e60546750f..c3080bbad5 100644 --- a/tests/testthat/_snaps/group_map.md +++ b/tests/testthat/_snaps/group_map.md @@ -1,7 +1,7 @@ # group_map() give meaningful errors Code - mtcars %>% group_by(cyl) %>% group_modify(~data.frame(cyl = 19)) + mtcars %>% group_by(cyl) %>% group_modify(~ data.frame(cyl = 19)) Error The returned data frame cannot contain the original grouping variables: cyl. diff --git a/tests/testthat/test-colwise-filter.R b/tests/testthat/test-colwise-filter.R index a9ea064edc..bbc0019865 100644 --- a/tests/testthat/test-colwise-filter.R +++ b/tests/testthat/test-colwise-filter.R @@ -66,5 +66,5 @@ test_that("colwise filter support .data$. in the quosure versions", { test_that("colwise filter() give meaningful errors", { expect_snapshot(error = TRUE, filter_if(mtcars, is_character, all_vars(. > 0))) - expect_snapshot(error = TRUE, filter_all(mtcars, list(~. > 0))) + expect_snapshot(error = TRUE, filter_all(mtcars, list(~ . > 0))) }) diff --git a/tests/testthat/test-deprec-funs.R b/tests/testthat/test-deprec-funs.R index 2501b26c86..089904fce5 100644 --- a/tests/testthat/test-deprec-funs.R +++ b/tests/testthat/test-deprec-funs.R @@ -123,5 +123,5 @@ test_that("funs() give meaningful error messages", { withr::local_options(lifecycle_verbosity = "quiet") expect_snapshot(error = TRUE, funs(function(si) { mp[si] })) - expect_snapshot(error = TRUE, funs(~mp[.])) + expect_snapshot(error = TRUE, funs(~ mp[.])) })