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

Confusing error message with pattern matching on polymorphic type in ae's native language #215

Open
Gbury opened this issue May 14, 2024 · 0 comments

Comments

@Gbury
Copy link
Owner

Gbury commented May 14, 2024

Consider the following problem:

type 'a list = Cons of {elt : 'a; tail : 'a list} | Nil

function length (list : 'b) : int =
  match list with
  | Nil -> 0
  | Cons(_, l') -> length(l') + 1
end

This results in the following error message:

File "tmp.ae", line 5, character 4-7:
5 |   | Nil -> 0
        ^^^
Error The constructor Nil : ∀ 'a : Type . list('a) does not belong to type w1

Which might be surprising to users. To help clarify things, it would help if:

  • the polymorphic type w1 could instead by named 'b as it is in the source
  • if the messages explicits that w1 is a type variable that is quantified over in the definition of length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant