Skip to content

invalid body argument for function

2 messages · Michael Lawrence, Duncan Murdoch

#
On 29/06/2011 9:09 PM, Michael Lawrence wrote:
I don't know if it's a bug.  The mkCLOSXP code has a list of types that 
it accepts; external pointers and environments aren't in that list, so 
you get the same error you saw with

fun<- eval(substitute(function() x, list(x = environment())))

There's a comment

/* This is called by function() {}, where an invalid
    body should be impossible. When called from
    other places (eg do_asfunction) they
    should do this checking in advance */


I don't know whether there's any reason for the restriction, but I'd 
want to look closely at what gets done with the body to make sure that 
putting an environment or external pointer or other weird type there 
doesn't cause other problems.

Duncan Murdoch