[Rd] Function Body / Formals Bug (PR#7495)

Robert.McGehee at geodecapital.com Robert.McGehee at geodecapital.com
Wed Jan 12 09:05:28 CET 2005


I'd like to report two bugs in the R function definitions, the first
slightly problematic, the second likely unimportant. Both of these are
reproducible on both Windows and Linux, R 2.0.1

First Bug:
> a <- new("function")
> formals(a) <- alist(a=, b=, c=, d=)
> a
function (a, b, c) ## the d argument disappeared!
> formals(a) <- alist(a=, b=, c=, d=)
> a
function (a, b, c, d) ## the d argument reappeared!

As you can see from above, the d= argument got chopped off completely
the first time "formals<-"() is called, but not the second! There must
be something funny going on with "formals<-"() when a function is first
initialized. I've also found a similar bug in which I try to assign a S4
object to the body of new function. It gives an error the first time,
with 

Error in as.function.default(x, envir) : argument must have length at
least 1

but if the same "body<-"() call runs again, the assignment runs without
error (still no assignment takes place). (I'll produce this S4 object
upon request, although I imagine these two errors are related). 

-----------------------------------------
Second Bug:
As I try to do more and more bizarre things on the R language, I came
across an incident where I (unintentionally) attempted to assign a
function to the body of another function. While I should expect to get
errors when I write meaningless things, I received the following error:

> a <- function() x
> body(a) <- function() y
Error in as.function.default(c(formals(fun), value), envir) : 
	invalid body argument for "function"
Should NEVER happen; please bug.report() [mkCLOSXP]

And as I've never been explicitly told by R to report a bug before, I
thought I'd comply, in case there are any wider ramifications to this
example above. If not, then I'm sure this second bug can be safely
ignored, as no one should be doing such things anyway.

Best,
Robert

Robert McGehee
Geode Capital Management, LLC
53 State Street, 5th Floor | Boston, MA | 02109
Tel: 617/392-8396    Fax:617/476-6389
mailto:robert.mcgehee at geodecapital.com



This e-mail, and any attachments hereto, are intended for use by the
addressee(s) only and may contain information that is (i) confidential
information of Geode Capital Management, LLC and/or its affiliates,
and/or (ii) proprietary information of Geode Capital Management, LLC
and/or its affiliates. If you are not the intended recipient of this
e-mail, or if you have otherwise received this e-mail in error, please
immediately notify me by telephone (you may call collect), or by e-mail,
and please permanently delete the original, any print outs and any
copies of the foregoing. Any dissemination, distribution or copying of
this e-mail is strictly prohibited.



More information about the R-devel mailing list