Skip to content

Type variable shadowing error

Type variable shadowing is broken since the new bidirectional type checking was introduced in 0.51.0. The below example type checked before 0.51.0.

Example:

type a = int

let f (type a) (x : a option) : a option =
  x

let main (_, st : unit * nat option) : ((operation) list * nat option) =
  match (f st) with
  | Some x -> ([], Some x)
  | None   -> ([], None)

Error:

  6 | let main (_, st : unit * nat option) : ((operation) list * nat option) =
  7 |   match (f st) with
  8 |   | Some x -> ([], Some x)

Invalid type(s)
Cannot unify "nat" with "int".