The compiler used to have a slightly different type inference logic between AssignmentStatement and VariableDeclarationStatement. While the former always called "updateLValueFromRValueTypes()" at the end of the validation, the later did not. As a result, as Cliff first discovered, processing of
Int? n = 0;
... // use n
was quite different from
Int? n;
n = 0;
... // use n
In the second scenario the compiler would "know" that "n" is not Null, while in the first one it did not, which is definitely wrong. The obvious solution was to add the following line at the end of VariableDeclarationStatement#updateLValueFromRValueTypes().
However, this simple fix uncovered a slew of bugs we have never seen before (the obvious reason we have not stepped onto any of those was that that Int? n; n = 0; style of variable initialization is quite unusual.
The good news is that the fix in this PR (on top of resolving the compilation inconsistency) made the compiler to uncover a couple of bugs that were not yet known (e.g. this line was missing, the Array API was a nothch off, and a couple of other small issues)
The compiler used to have a slightly different type inference logic between AssignmentStatement and VariableDeclarationStatement. While the former always called "updateLValueFromRValueTypes()" at the end of the validation, the later did not. As a result, as Cliff first discovered, processing of
was quite different from
In the second scenario the compiler would "know" that "n" is not Null, while in the first one it did not, which is definitely wrong. The obvious solution was to add the following line at the end of VariableDeclarationStatement#updateLValueFromRValueTypes().
However, this simple fix uncovered a slew of bugs we have never seen before (the obvious reason we have not stepped onto any of those was that that
Int? n; n = 0;
style of variable initialization is quite unusual.The good news is that the fix in this PR (on top of resolving the compilation inconsistency) made the compiler to uncover a couple of bugs that were not yet known (e.g. this line was missing, the Array API was a nothch off, and a couple of other small issues)