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 (960 forks)batch import
help wanted

Repository metrics

Stars
 (21,417 stars)
PR merge metrics
 (Avg merge 10d 19h) (69 merged PRs in 30d)

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