Assuming declarations are expressions consider such code:
if ((var x = foo()) and (var y = x)) or (var z = bar()) then println(z); end
The reference to
x is OK, because at this point
x has to be set, but the reference to
println) is not. It can be valid or not.
I would like to compute those two "states" of variables -- whether it is OK to reference variable (it is guaranteed it is set) or no (it is not set for sure, or it is maybe set).
How to do it?
Update: I found this wiki page https://en.wikipedia.org/wiki/Definite_assignment_analysis and I think my case is much easier. I need to keep track of 4 kinds of flow -- and, or, xor, next (comma operator, from predicate to body). I hope I am right :-)