Add an icon for recursive calls
Opened this issue · 3 comments
I'm not sure if it's easy to implement but if it's possible, it would be helpful to have an icon next to the line number where a recursive call appears (like it is implemented in jetbrains products).
This can be implemented using the use
command of nimsuggest
https://nim-lang.org/docs/nimsuggest.html#nimsuggest-invocation-symbol-usages
Basic algorithm that matches some recursive procs:
For each symbol that is a proc:
lookup usage using use command
if at least one usage inside thisProcStartIndex ... thisProcEndIndex:
set the current proc as recursive proc (an icon next to the line number of thisProcStartIndex)
elif usage in otherProc and otherProc called in thisProc: also recursive
Maybe this algorithm can be run in the background with low priority.
Hello,
Two or more mutually dependent procedure calls can exist. Same error of code but not easy to detect with this alone. You have to actually create a dependency graph and decide how deep each graph can check. You may be happy that you have no cycles at depth of length 10.
The scenario occurs when one func or proc is so useful that it is made a core piece of another. An example is a len(gth) proc using a bounds checking syntax ([…]) that refers to the last element by length. Would this be okay for tail recursive style implementations? Thank you. Good day.
@pr-yemibedu Yes, having a full support for the detection of recursive procs is difficult and maybe too much here. My idea was to detect only those recursive procs that don't require deep analysis.