Skip to content

Fix polymorphic kvar type variable mismatch and add regression tests#2651

Merged
facundominguez merged 6 commits intodevelopfrom
fd/polykvars2
Apr 13, 2026
Merged

Fix polymorphic kvar type variable mismatch and add regression tests#2651
facundominguez merged 6 commits intodevelopfrom
fd/polykvars2

Conversation

@facundominguez
Copy link
Copy Markdown
Collaborator

This PR fixes #2649.

It depends on ucsd-progsys/liquid-fixpoint#837

Now liquidhaskell can specify how type variables in kvar solutions should be instantiated. This is possible to discover when encountering type applications during constraint generation.

liquid-fixpoint will then substitute the type variables when applying kvar solutions.

@facundominguez facundominguez force-pushed the fd/polykvars2 branch 3 times, most recently from 215059b to f350a7f Compare April 13, 2026 10:52
- 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
@facundominguez facundominguez merged commit 31e83d2 into develop Apr 13, 2026
6 checks passed
@facundominguez facundominguez deleted the fd/polykvars2 branch April 13, 2026 13:35
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.

Mismatched sorts in PLE + FUSION

1 participant