Skip to contents

A function rebuilt from another one, for example by changing its default arguments with formals<-, loses its own srcref but keeps the original body, along with the body's srcrefs. Such a function is given the srcref of the namespace function whose body has exactly the same srcrefs, so both share code and tests, as an alias (a <- b) does.

Usage

copied_srcrefs(ns, exclude = character())

Arguments

ns

A package namespace environment

exclude

A character vector of object names that already have srcrefs

Value

A list of srcrefs, named by the copy they belong to

Details

Only bodies in braces carry srcrefs, so a copy of a function like function(x) x + 1 can't be matched this way.