Skip to content

Conversation

@purefunctor
Copy link
Owner

No description provided.

This fixes a bug in implicit variable resolution where variables in
instance heads are all lowered into Implicit variables rather than
becoming Bound.
Following the changes in the previous commit, this adds subtyping and
unification rules for Implicit and Bound variables. Previously, instance
heads only contained Implicit variables which can be unified trivially.
This removes an erroneous fix now that the lowering properly emits
Implicit / Bound variables in the instance head, which means that the
`a` in `instance TypeEq a a` now refer to the same logical variable
instead of binding `a` twice.
This completely reworks the checking code for types, reducing the number
of implicit invariants that using global mutable state introduced.
This commit also changes the instance chain search in the constraint
solver to properly consider instances that appear in the files of any
Type::Constructor involved in a constraint being solved.
The removal of Variable::Implicit uncovered a bug in instance checking
where promote_type began throwing an escaped skolem error in previously
valid types. Variable::Implicit was excluded from this check, and it
turns out that the instance head checking was producing invalid ones.
Instance head checking would use ShiftImplicit to correctly adjust the
levels after generalisation. The problem was that in instance member
checking, this was not applied; thus, the unification of Implicit and
Bound exposed the issue through promote_type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants