[Chapel Merge] Split initialization for multi-variable declaratio

Branch: refs/heads/master
Revision: c8125bc
Author: slnguyen
Log Message:

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

Modified Files:
A test/variables/backPropagateInFunction.chpl
A test/variables/backPropagateInFunction.good
A test/variables/backPropagateInitVar.chpl
A test/variables/backPropagateInitVar.good
M compiler/AST/build.cpp
M compiler/optimizations/preNormalizeOptimizations.cpp
M compiler/passes/checkParsed.cpp
M compiler/passes/cleanup.cpp
M test/classes/hilde/nestedRecordAssignment.chpl
M test/classes/hilde/records/assignReturns-error.chpl
M test/classes/hilde/records/assignReturns-error2.chpl
M test/expressions/hilde/assignopLHSargIsRef.chpl
M test/functions/ferguson/generic-record-assign.chpl
M test/functions/vass/ambiguous-assignment.chpl
M test/functions/vass/ambiguous-assignment.good

Compare: https://github.com/chapel-lang/chapel/compare/ec4c925b07a9...c8125bc65b28