Skip to content

Invalid pattern matching translation on nullary constructors #17

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

Open
4ever2 opened this issue Mar 31, 2025 · 0 comments
Open

Invalid pattern matching translation on nullary constructors #17

4ever2 opened this issue Mar 31, 2025 · 0 comments

Comments

@4ever2
Copy link

4ever2 commented Mar 31, 2025

In some cases pattern matching gets "optimized" during translation in cases that match on nullary constructors and return the same constructor. I.e. we get

match x
  case CONSTRUCTOR1 -> x

rather than

match x 
  case CONSTRUCTOR1 -> CONSTRUCTOR1

This is problematic for the typed targets if the inductive type contains type variables, since the constructor matched and the constructor returned could have different type variables.
This only seems to happen in some cases, for example it happens in the map example but not in the double example.

map : {A B : Set} -> (A → B) → List A → List B
map f empty = empty
...
double : Nat → Nat
double zero = zero
...
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

No branches or pull requests

1 participant