@@ -83,7 +83,6 @@ check_length <- function(x, length = integer(), ..., min = 0, max = Inf,
8383 if (n %in% length ) {
8484 return (invisible (NULL ))
8585 }
86- fmt <- if (inherits(arg , " AsIs" )) identity else function (x ) sprintf(" `%s`" , x )
8786 if (length(length ) > 0 ) {
8887 type <- paste0(" a vector of length " , oxford_comma(length ))
8988 if (length(length ) == 1 ) {
@@ -96,7 +95,7 @@ check_length <- function(x, length = integer(), ..., min = 0, max = Inf,
9695 }
9796 msg <- sprintf(
9897 " %s must be %s, not length %d." ,
99- fmt (arg ), type , n
98+ fmt_arg (arg ), type , n
10099 )
101100 cli :: cli_abort(msg , call = call , arg = arg )
102101 }
@@ -122,7 +121,7 @@ check_length <- function(x, length = integer(), ..., min = 0, max = Inf,
122121
123122 msg <- sprintf(
124123 " `%s` must be a %s with %s, not length %d." ,
125- fmt (arg ), type , what , n
124+ fmt_arg (arg ), type , what , n
126125 )
127126 cli :: cli_abort(msg , call = call , arg = arg )
128127}
@@ -419,3 +418,10 @@ check_device <- function(feature, action = "warn", op = NULL, maybe = FALSE,
419418.blend_ops <- c(" multiply" , " screen" , " overlay" , " darken" , " lighten" ,
420419 " color.dodge" , " color.burn" , " hard.light" , " soft.light" ,
421420 " difference" , " exclusion" )
421+
422+ fmt_arg <- function (x ) {
423+ if (inherits(x , " AsIs" )) {
424+ return (x )
425+ }
426+ sprintf(" `%s`" , x )
427+ }
0 commit comments