-
Notifications
You must be signed in to change notification settings - Fork 35
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
Constraint solver #284
Constraint solver #284
Conversation
Good progress! But no tests? I am curious to which polymorhic definitions and usages of polymorphic functions this solves. Also, is there any example of what should fail but doesn't because of the non-transitive compatible-subtyping issue? I'll look more another day, but it's a bit hard to grasp without tests. Also, it would be nice if you can avoid adding tabs and avoid converting existing indentation from spaces to tabs. |
This is my first stab at the constraint solver. It is only very lightly tested and is not hooked in to the type checker yet.
When checking toplevel functions, call the constraint solver to work out if the existential types are correct. Unimplemented: * Applying the substitution on the remaining types. * Check that the remaining constraints are compatible with the constraints declared in the spec. I fixed a few bugs in the process.
A variable might not have any constraints and that's fine!
Keeping the constraints when checking unions requires having a union of constraints and the current implementation doesn't support that. So right now we just drop the constraints. This means that we currently don't report as many type errors as one might expect.
The current representation for constraints cannot handle union types so the constraints are dropped for now. This means that some type errors will not be caught.
06d0ad2
to
cd5d502
Compare
The function instantiate_fun_type now returns constraints which have to be propagated. This was caught by dialyzer
Codecov Report
@@ Coverage Diff @@
## master #284 +/- ##
==========================================
- Coverage 87.39% 86.67% -0.72%
==========================================
Files 18 18
Lines 2728 2800 +72
==========================================
+ Hits 2384 2427 +43
- Misses 344 373 +29
Continue to review full report at Codecov.
|
5b14081
to
c5c63d4
Compare
I accidentally pushed to this branch yesterday instead of my WIP fork. Fixing it in a second... |
c5c63d4
to
5b14081
Compare
Codecov ReportBase: 87.39% // Head: 86.67% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #284 +/- ##
==========================================
- Coverage 87.39% 86.67% -0.72%
==========================================
Files 18 18
Lines 2728 2800 +72
==========================================
+ Hits 2384 2427 +43
- Misses 344 373 +29
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
...and fixed. |
Superseded by #450. |
This is a technology preview of the constraint solver I've been working on. This is a very simple solver which doesn't handle union types properly, so there are programs which will still pass the typechecker despite not being welltyped. That being said, it can catch a fair amount of typeerrors where type variables are involved.
[Edit: removed comment about bug that I've now fixed.]