diff --git a/NEWS.md b/NEWS.md index 08b5074d..50aae7b0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # purrr (development version) +* Fixed valgrind issue. + * Deprecation infrastructure in `map_chr()` now has much less overhead leading to improved performance (#1089). diff --git a/src/coerce.c b/src/coerce.c index 2cc6a6fc..e3bc9071 100644 --- a/src/coerce.c +++ b/src/coerce.c @@ -6,11 +6,34 @@ #include "conditions.h" void cant_coerce(SEXP from, SEXP to, int i) { + + const char* to_friendly; + switch(TYPEOF(to)) { + case INTSXP: + to_friendly = "an integer"; + break; + case REALSXP: + to_friendly = "a double"; + break; + case STRSXP: + to_friendly = "a string"; + break; + case LGLSXP: + to_friendly = "a logical"; + break; + case RAWSXP: + to_friendly = "a raw vector"; + break; + default: + to_friendly = Rf_type2char(TYPEOF(to)); + } + + Rf_errorcall( R_NilValue, "Can't coerce from %s to %s.", rlang_obj_type_friendly_full(from, false, false), - rlang_obj_type_friendly_full(to, false, false) + to_friendly ); } diff --git a/tests/testthat/_snaps/map.md b/tests/testthat/_snaps/map.md index 3fa0ac7c..7ad15343 100644 --- a/tests/testthat/_snaps/map.md +++ b/tests/testthat/_snaps/map.md @@ -29,7 +29,7 @@ Error in `map_int()`: i In index: 3. Caused by error: - ! Can't coerce from a string to an integer vector. + ! Can't coerce from a string to an integer. Code map(1:3, ~ fail_at_3(.x, stop("Doesn't work"))) Condition