Add compile warnings for infinite while loops
If a while loop uses a counter and has no foreseeable exit condition, I would like a compile warning to be added. This way, the user can correct this error before it crashes their plugin.
void myInfiniteWhileLoop()
{
int index = 20;
while (index >=0)
{
PrintToChatAll("I like apples");
}
}
This example may be better suited for a for-loop. But there are other use cases with multiple conditions.
There's not a lot we can do here without running into the halting problem. At best, we could detect that the condition was invariant across the loop, which would only be possible if the condition used local variables. That might be worth doing but we're a ways off from being able to do that.
I believe SM enables the watchdog timer, so if you do infinite loop, you should get a timeout after a few seconds.