You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
For the straightforward cases, we can add that. I just didn't look for function definitions explicitly.
Not certain yet where I want to do this without giving it a little thought, i.e. in CodeAnalysis or in CodeDepends. I'll try to find time to rationalize the separation and role of each of these in the next few weeks.
There's also a related issue with TryCatch. That is, tryCatchList uses tryCatchOne that's only defined later in the body. I'm mentioning it here so we don't forget.
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]]
wheretryCatchList
defines and uses itself. One can useRecall
to 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
getInputs
states:I understand this to mean that it doesn't recursively look at all functions called.
The text was updated successfully, but these errors were encountered: