hashc
hashc copied to clipboard
sc: Separate discovery and some of resolution into a separate scope-check pass
The idea is to transition to having the following passes after untyped analysis:
-
Scope checking: This checks that all declarations are referenced in a valid way, there are no undeclared references, and no circular references. The output of this stage should be something like a "name graph" of all the scopes, declarations, and their references.
-
TIR lowering: This pass simply takes the AST, and with the help of the output of the previous stage, it constructs the TIR tree.
-
Type checking: this populates the TIR with types and ensures that everything is well typed. Here, some compile-time evaluation also occurs.
Currently, all these are bundled into the semantic analysis pass, which does discovery (now scope checking), resolution (now TIR lowering), and type checking. They should be broken up to make the codebase simpler, to be able to gather more granular metrics, and to be able to abstract the stages further and reduce inter-dependence. (e.g. scope checking does not need to know at all about TIR)