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

[ fix ] handling of VCase in Core.Case.Builder.sameType #35

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlgebraicWolf
Copy link
Contributor

Current implementation of headEq inside Core.Case.Builder.sameType considers two VCases to always be different. Because of this, the following example fails to compile.

module Main

public export
record X (flag : Bool) where
  constructor MkX
  x : if flag then Bool else Void

f : X True -> ()
f (MkX True) = ()
f (MkX False) = ()

Instead, the following compilation error is produced:

Error: Patterns for f require matching on different types.

Main:13:1--13:18
 09 |   constructor MkX
 10 |   x : if flag then Bool else Void
 11 |
 12 | f : X True -> ()
 13 | f (MkX True) = ()
      ^^^^^^^^^^^^^^^^^

This patch changes the behaviour of headEq to make it treat VCases as equal, eliminating the error.

Current implementation of `headEq` inside `Core.Case.Builder.sameType`
considers two `VCase`s to always be different. Because of this, the
following example fails to compile.

```idris
module Main

public export
record X (flag : Bool) where
  constructor MkX
  x : if flag then Bool else Void

f : X True -> ()
f (MkX True) = ()
f (MkX False) = ()
```

Instead, the following compilation error is produced:

```
Error: Patterns for f require matching on different types.

Main:13:1--13:18
 09 |   constructor MkX
 10 |   x : if flag then Bool else Void
 11 |
 12 | f : X True -> ()
 13 | f (MkX True) = ()
      ^^^^^^^^^^^^^^^^^
```

This patch changes the behaviour of `headEq` to make it treat `VCase`s
as equal, eliminating the error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant