Skip to content

Improve uninitialized variable detection at compile time

The parser marks a variable that has not been affected as uninitialized, so the following code produces a clean error at compile time

let x:R;
2+x;

However if a value is possibly given to x, the variable is marked as initialized. For instance, if one uses the following code

let x:R;
if (false) {
  x = 3;
}
2+x;

even if the instruction x = 3; is not reachable, the variable is marked as initialized by the parser. This leads to a crash at execution, without any helpful information.

Actually, fixing this behavior is not that easy, but it should be helpful.