Merge pull request #16520 from slnguyen/i16371
Split initialization for multi-variable declarations in functions
This PR makes the following changes:
- for multivariable declarations in functions, the back propagation of initialization type is moved from the parse pass (in build.cpp) to the cleanup pass (in cleanup.cpp). Doing so allows us to create a temporary type representing the initialization type and assigning the temporary type to each variable in the multivariable declaration. This way for the line var a, b: Point;, both a and b will be initialized with the temporary type, b will not be initialized with ‘typeof’ a, allowing split initialization to be applied.
- moves call of the backPropagateInitsTypes function in build.cpp from buildVarDecls to buildClassDefExpr so that it only applies to class fields. Class fields are treated differently because an AggregateType has an AList of fields and it wouldn’t make sense to add a temporary to these.
- to avoid errors for multi-variable declarations before their types/inits are established, adding gSplitInit and the check for variables not initialized and with no type is moved from the checkParsed pass to cleanup.
- modifies several tests of assignment to avoid split initialization now that split initialization applies to them.
- adds two tests, one tests for the first point of this list and the other tests if variables are initialized correctly.
Reviewed by @mppf