Consider reframing internal compiler typing logic to be "locally-based constraint solving" instead of "globally-based" #3403
Labels
compiler: frontend
Everything to do with type checking, control flow analysis, and everything between parsing and IRgen
Needs RFC
Features that require an RFC before proceeding with an implementation
Previously the compiler has relied on a globalTypeEngine
in order to complete type inference. Now that there is a PR to remove this (#3353), we can begin to think about introducing an internal change to the how theTypeEngine
that will make understanding and contributing to the type system much easier and will reduce the scope of new changes significantly.Instead of approaching type constraint solving "globally", we should change it to be more "local" (I'm making these phrases up as a go so I'll try my best to explain). Essentially what I'm trying to say is that exposing all types across all scopes of the program is adding unnecessary complexity. For example, when doing type inference in a function body, the types that you need are 1) from the scope surrounding the function body and 2) from the scope of the function body itself. You don't need to drag around the types from inside the declaration in the previous declaration block, which is what the globalTypeEngine
does.I think that this issue manifests in the fact that local constraint solving is not fully solved right now. For example, #3324 demonstrates that there is an issue resolving types with match expressions (although there is a fix in #3348).Notes:
The text was updated successfully, but these errors were encountered: