Python has methods like getattr() which can be used to branch arbitrarily at runtime. As a result, static code analysis tools can't be certain what functions a program will call. A good example comes from Vulture, which is a library that tries to find dead code:
import os class Greeter: def greet(self): print("Hi") def hello_world(): message = "Hello, world!" greeter = Greeter() func_name = "greet" greet_func = getattr(greeter, func_name) greet_func() if __name__ == "__main__": hello_world() In the above example, func_name must be evaluated to know where the program would branch.
Are there programming languages that intentionally or unintentionally ensure static analysis tools will always be able to tell where a function will branch? If so, what are some examples?
Secondarily, is there name for this property?
Edit: Per D.W.'s answer, possible branches would include unreachable code and code behind if False:, etc.
if f() then g()requires thatfterminates forgto be called. $\endgroup$