Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider reframing internal compiler typing logic to be "locally-based constraint solving" instead of "globally-based" #3403

Closed
emilyaherbert opened this issue Nov 21, 2022 · 0 comments
Assignees
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

Comments

@emilyaherbert
Copy link
Contributor

emilyaherbert commented Nov 21, 2022

Previously the compiler has relied on a global TypeEngine 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 the TypeEngine 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 global TypeEngine 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:

@emilyaherbert emilyaherbert added 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 labels Nov 21, 2022
@emilyaherbert emilyaherbert self-assigned this Jan 10, 2023
@IGI-111 IGI-111 closed this as completed May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants