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

Check declared variable's types with equality instead of unification #170

Open
jfecher opened this issue Dec 8, 2023 · 1 comment
Open
Labels
good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement type system For issues related to Ante's type system

Comments

@jfecher
Copy link
Owner

jfecher commented Dec 8, 2023

If a variable or function is declared with a type signature it is currently unified against the type of the right hand side expression instead of simply checked for equality. This means that the following snippet:

foo (x: a) : a = x + 1

Type checks despite the actual inferred type of foo being Int a -> Int a. To fix this, we'll need to check for type equality if a type signature is already present, and fallback to unification only if it is not. When checking type equality we'll need to be careful to call follow_all_bindings on each type to ensure any type variable links are already followed, otherwise they can fail the equality check on otherwise equal types.


I'm marking this "good first issue" mostly for those already familiar with Hindley Milner type systems as it only requires learning part of Ante's type checking pass.

@jfecher jfecher added good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement type system For issues related to Ante's type system labels Dec 8, 2023
@jfecher
Copy link
Owner Author

jfecher commented Dec 17, 2023

Fixing this should also fix #168

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue An issue that doesn't require deep knowledge of the compiler to fix or implement type system For issues related to Ante's type system
Projects
None yet
Development

No branches or pull requests

1 participant