void example1()
{
int counter;
if (counter == 0)
writeln("First run");
counter++;
}
void example2()
{
string[string] cache;
if (cache is null)
cache = populateCache();
// ... use cache ...
}
In both cases, we are missing static from the local variable. Though we cannot infer the intent, we can at least determine and point out that comparing the variable with its only possible value at that time doesn't really make sense.
This could be something as complicated as value propagation but also as simple as just checking whether the variable has ever been initialized since it was declared.