gleam-lang / gleam

⭐️ A friendly language for building type-safe, scalable systems!
https://gleam.run
Apache License 2.0
17.52k stars 727 forks source link

Unbound type variable in top level definition after type inference #2533

Open giacomocavalieri opened 8 months ago

giacomocavalieri commented 8 months ago

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) { ... }
lpil commented 8 months ago

Thank you. I believe there are no consequences of this, but it does imply there's an issue with the typer.