Bug 17339 - `body<-` does not preserve attributes
Summary: `body<-` does not preserve attributes
Status: UNCONFIRMED
Alias: None
Product: R
Classification: Unclassified
Component: Language (show other bugs)
Version: R 3.3.*
Hardware: All Linux
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2017-09-12 18:40 UTC by Neal Fultz
Modified: 2017-09-12 18:40 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neal Fultz 2017-09-12 18:40:03 UTC
`body<-` appears to not preserve attributes set on functions. Sometimes I use attributes on functions, eg for memoization, etc. Here is a small test case:

> f <- structure(function(x) x+1, foo='bar')
> attributes(f)
$srcref
function(x) x+1

$foo
[1] "bar"

> body(f) <- body(mean)
> attributes(f)
NULL

I would expect changing the body to not affect the attributes at all.