MichaelChirico / r-bugs

A ⚠️read-only⚠️mirror of https://bugs.r-project.org/
20 stars 0 forks source link

[BUGZILLA #17339] `body<-` does not preserve attributes #6514

Open MichaelChirico opened 4 years ago

MichaelChirico commented 4 years ago

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.


METADATA

github-actions[bot] commented 4 years ago

NA


METADATA