Skip to content
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

Wingman incorrectly unifies skolems across apart GADT matches #1937

Closed
isovector opened this issue Jun 17, 2021 · 2 comments · Fixed by #1942
Closed

Wingman incorrectly unifies skolems across apart GADT matches #1937

isovector opened this issue Jun 17, 2021 · 2 comments · Fixed by #1942
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@isovector
Copy link
Collaborator

data AST a where
    BoolLit :: Bool -> AST Bool
    IntLit :: Int -> AST Int

eval :: AST a -> a
eval = [wingman| intros x, destruct x |]

with resulting goals:

2 goals

b :: Bool  
⊢ Bool

n :: Int  
⊢ Bool

Except that no! That second goal should be ⊢ Int.

What's happening here is that unification gets tracked in the TacticState, which is shared across the entire search tree. Thus, in the first branch, we learn that a ~ Bool, and this fact never gets invalidated when we enter the IntLit case.

@TOTBWF any good idea about what to do here?

@isovector isovector added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. component: wingman labels Jun 17, 2021
@isovector
Copy link
Collaborator Author

I've always wondered, but maybe this is what coercions do. If they exist at the value level, then they'd go out of scope between the GADT matches. Maybe we can do something similar, tracking coercions in the Judgement, and combining their evidence with the TacticState unification just in time.

@isovector
Copy link
Collaborator Author

On further thought, I don't think this is directly related to the TacticState at all. The only time we change the TCvSubst is for type variables that are not skolems, which means it's definitely the GADT evidence going wrong here. I think those get directly injected into the ts_subst, rather than doing anything scoped.

isovector added a commit to isovector/haskell-language-server that referenced this issue Jun 17, 2021
jneira pushed a commit that referenced this issue Jun 18, 2021
* Properly scope GADT equality evidence in the judgment

Fixes #1937

* Haddock and a bit of refactoring

* Track coercions in a TCvSubst instead
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: wingman type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant