You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (is.primitive(reduce) &&!is.null(attr(reduce, "init", exact=TRUE))) {
479
+
## FIXME?: At least in R 4.4.3, none of the primitive functions have
480
+
## attributes. Because of that, we could do attributes(reduce) <- NULL
481
+
## here before throwing the error. But is that a safe assumption?
482
+
name<- name_of_function(reduce)
483
+
nameq<-name
484
+
if (!grepl("^[[:alpha:]]", nameq)) nameq<- sprintf("`%s`", nameq)
485
+
stop(sprintf("You must not set an 'init' reduce value on 'base' function %s(), because it is a primitive function. You can use 'reduce = structure(\"%s\", init = <value>)' instead", nameq, name))
486
+
}
487
+
} else {
474
488
args<- names(formals(reduce))
475
489
if (length(args) ==0) {
476
490
stop("The 'reduce' function must take at least one argument")
477
491
}
478
492
}
479
-
}
480
-
481
-
## SPECIAL CASE: Protect against mistakes
482
-
## See R-devel thread '[Rd] structure(<primitive function>, ...) is
483
-
## sticky: a bug, or should it be an error?' on 2025-03-19
if (is.primitive(reduce) &&!is.null(attr(reduce, "init", exact=TRUE))) {
486
-
## FIXME?: At least in R 4.4.3, none of the primitive functions have
487
-
## attributes. Because of that, we could do attributes(reduce) <- NULL
488
-
## here before throwing the error. But is that a safe assumption?
489
-
name<- name_of_function(reduce)
490
-
nameq<-name
491
-
if (!grepl("^[[:alpha:]]", nameq)) nameq<- sprintf("`%s`", nameq)
492
-
stop(sprintf("You must not set an 'init' reduce value on 'base' function %s(), because it is a primitive function. You can use 'reduce = structure(\"%s\", init = <value>)' instead", nameq, name))
0 commit comments