Skip to content

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

@Gbury

Description

@Gbury

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions