gleam-lang/gleam

Unbound type variable in top level definition after type inference

Open

#2,533 opened on Jan 9, 2024

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Rust (21,417 stars) (960 forks)batch import
help wanted

Description

In this case, after type inference, the main function ends up having an inferred type with an unbound type variable instead of a generic one:

pub type Foo(a) {
  Foo(value: Int)
}

pub fn main() {
  Foo(1)
}

Adding a type annotation turns the variable into a generic one though:

// now the inferred type has a generic type variable instead
// of an unbound one
pub fn main() -> Foo(a) { ... }

Contributor guide