-
Notifications
You must be signed in to change notification settings - Fork 27
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
Required fields taken #22
Comments
seems the order of constraint solving is wrong #22
Actually, this is not a bug, it's intended behaviour. The fix commit breaks soundness of the subtyping relation, so you'll want to revert that. |
You're allowed to "take" discardable fields from records as part of the subtyping relation now. |
This exampled didn't typecheck before my last change. If you used |
reverted in ee00083 |
@liamoc Still don't get why in |
This is a separate bug than the previous one. I see why this is happening but I'm struggling to figure out a nice way to fix it. Basically, the free call is introducing a constraint like
And the member call only generates a constraint like:
which is only checked once ?11 is resolved. This may require me to design the solver quite differently. It'll need some serious thinking. |
OK, I think I've figured out the changes I need to make, although it's quite a significant amount of refactoring. Might take me a while. |
OK, If you want you can merge my tc-new branch. It fixes this bug. I've gotten rid of those Partial or :<~ constraints entirely. Now we have just subtyping (and a separate constraint Upcastable specifically for integers). Subtyping, however, is now a relation on type fragments, which may be:
This type is non-recursive, and we never instantiate type variables to type fragments (meaning that our substitution type still is effectively a map from variables to Now the solver will group regular and "partial" subtyping constraints together, and solve them together. This solves this bug as this bug is caused by the (non-partial) subtyping constraints being solved first -- then the partial constraints fail. We need to come up with solutions that satisfy all the constraints, and a solution that satisfies just the non-partial subtyping constraints will not be a safe solution for the partial ones.. hopefully that makes sense. The code in the solver is now quite repetitive though, so if anyone wants to have a go at refactoring it (while preserving semantics) it might be a nice thing. |
OK, I'm in the process of writing up this algorithm now, and I realised there's probably still a bug here. The general gist of the solver is that it groups subtyping constraints by their variable (and whether it occurs on the left or right hand side). So for example all constraints of the form The possible bug is that if there are flex-flex constraints, e.g The fix is, if we have only one flex-rigid constraint Posting this mostly as a reminder to myself to try to fix this possible problem and see if it breaks anything. I haven't found an example program that breaks, but the algorithm may give surprising results, I'm not sure. |
OK, I've convinced myself that it's safe to delay flex-flex constraints. Because, if we have a solution for Should we close this issue? |
No, the same symptom (... of type ... is required but has been taken) appears again in ext2. I'm still working on shrinking the code. |
Once this one passes, should also try pass_ext2-mount.cogent
Under d10fa13, the |
Alright, I stepped through (a further simplified version of) this example, running the algorithm by hand. I figured out what's wrong. The constraints you end up with are something like:
In this scenario, the solver sees a "no-brainer" opportunity for |
OK, I've pushed a series of commits to my fork. Merge whenever. It passes all the pass_ tests (including one test that should never have been passing, but I fixed the test case). Now it will not solve (i.e. generate a substitution for) any "no-brainer" constraint while there are still flex/flex constraints about the same variable (for this check we ignore reflexive constraints This doesn't seem to have caused any regressions. I'm also working on better handling of constraints like
Now this transforms into:
And similar. I haven't finished all the |
After some testing, I think transforming Now it will simply not solve any system of constraints involving such type operators until they can be evaluated. Also, I've discovered a really simple way to explain how this algorithm works now which suggests I'm on the right track. |
Once this one passes, should also try pass_ext2-mount.cogent
seems the order of constraint solving is wrong #22
Once this one passes, should also try pass_ext2-mount.cogent
No description provided.
The text was updated successfully, but these errors were encountered: