Merge pull request #17740 from mppf/move-type-init-to-decl
Move typeExpr/initExpr to Formal/Variable Decl
This PR changes the typeExpr and initExpr for Formal and Variable to be
stored in the FormalDecl or VariableDecl rather than in the Sym.
There are three reasons for this.
First, the previous strategy was intended to preserve a property that all
Decls will have just one child. That's no longer true now that we have
MultiDecl (and we will soon also have TupleDecl).
Second, when we assign IDs to Symbols, we do that in a different manner
for Syms vs Expressions. Syms are named with the symbol name but
Expressions just get a postorder traversal integer within the parent Sym.
I'd like scope-resolution to be able to use these IDs in a natural
manner. So, I'd like only those Syms that create a new scope to contain
children. (E.g. Function creates a scope for the formals and body; but
Variable does not introduce a new scope). So it is more natural for the
VariableDecl/FormalDecl to contain the typeExpr/initExpr.
Third, storing the typeExpr/initExpr in the FormalDecl/VariableDecl was
requested by a reviewer in earlier discussions.
Reviewed by @lydia-duncan - thanks!
Modified Files: M compiler/next/include/chpl/uast/ASTClassesList.h