If a function is defined locally and calls itself (so it's recursive), then ideally CodeDepends should identify that the usage of the function is local, and not from a package. This came up for me in tryCatch, specifically getInputs(tryCatch)[[3L]] where tryCatchList defines and uses itself. One can use Recall to achieve the same result.
Here's a minimal example:
add_123 = function(x){
add = function(y, ...){
if(!missing(y)){
y + add(...)
#y + Recall(...) # Alternatively
} else 0
}
add(x, 1, 2, 3)
}
info = getInputs(add_123)
info[[3]]@functions["add"] # FALSE, should be TRUE
info[[4]]@functions["add"] # TRUE, as expected
I can work around this behavior by checking if the name of the function used is also an output.
The documentation for the functions slot from getInputs states:
Note that this is not recursive.
I understand this to mean that it doesn't recursively look at all functions called.
If a function is defined locally and calls itself (so it's recursive), then ideally CodeDepends should identify that the usage of the function is local, and not from a package. This came up for me in
tryCatch, specificallygetInputs(tryCatch)[[3L]]wheretryCatchListdefines and uses itself. One can useRecallto achieve the same result.Here's a minimal example:
I can work around this behavior by checking if the name of the function used is also an output.
The documentation for the functions slot from
getInputsstates:I understand this to mean that it doesn't recursively look at all functions called.