Bug 15691 - callGeneric broken with .local() and function object in call
Summary: callGeneric broken with .local() and function object in call
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: S4methods (show other bugs)
Version: R 3.0.2
Hardware: Other Linux
: P5 minor
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2014-02-26 13:13 UTC by Michael Lawrence
Modified: 2014-03-03 11:33 UTC (History)
0 users

See Also:


Attachments
Fixes the issue by not assuming the first element of the call is a symbol (1.14 KB, patch)
2014-02-26 13:13 UTC, Michael Lawrence
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Lawrence 2014-02-26 13:13:46 UTC
Created attachment 1573 [details]
Fixes the issue by not assuming the first element of the call is a symbol

Found this one recently:

setGeneric("fun", function(x, ...) standardGeneric("fun"))

setMethod("fun", "character", identity)
setMethod("fun", "numeric", function(x) {
  x <- as.character(x)
  callGeneric()
})

fun(1)
# [1] "1"
do.call(fun, list(1))
# Error in as.vector(x, "character") (from #3) : 
#  cannot coerce type 'closure' to vector of type 'character'

Obvious problem is that the call has the function (or primitive) object instead of a symbol. Attached patch fixes this.
Comment 1 Brian Ripley 2014-03-03 11:33:12 UTC
Applied to R-devel, for R 3.1.0.