Fix polymorphic kvar type variable mismatch and add regression tests#2651
Merged
facundominguez merged 6 commits intodevelopfrom Apr 13, 2026
Merged
Fix polymorphic kvar type variable mismatch and add regression tests#2651facundominguez merged 6 commits intodevelopfrom
facundominguez merged 6 commits intodevelopfrom
Conversation
215059b to
f350a7f
Compare
- Update PKVar constructor to 3 parameters across liquidhaskell-boot
(Expand.hs, Generate.hs, Parse.hs, Fresh.hs, RType.hs, Types.hs)
- Add regression test PolyKVar2649.hs exercising polymorphic kvars
where a function with kvar-inferred specs is called from a different
type variable context
In consEApp, after instantiating predicates during a type application,
traverse the result type and stamp every PKVar with the type variable
mapping {symbol(α) → sort(τ)}. This records how type variables are
instantiated, so the solver can apply correct sort substitutions when
the same kvar is used across different type variable contexts.
Fixes #2649.
Written with Copilot
PolyKVar2649a: simpler variant from the issue comments — a helper function with open kvar refinements called from a function requiring a concrete Set-based postcondition. PolyKVar2649b: original issue example — a local go function with a different type variable than the outer uniques function. Both tests verify the fix produces proper Liquid Type Mismatch errors rather than crashing with a sort mismatch in elaboration. Written with Copilot
Update all PKVar pattern matches in liquidhaskell-boot to match the new PKVar constructor order: tsu (TyVarSubst) before su (KVarSubst). Written with Copilot
eb0e687 to
583b228
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes #2649.
It depends on ucsd-progsys/liquid-fixpoint#837
Now
liquidhaskellcan specify how type variables in kvar solutions should be instantiated. This is possible to discover when encountering type applications during constraint generation.liquid-fixpointwill then substitute the type variables when applying kvar solutions.