inko-lang / inko

A language for building concurrent software with confidence

Home Page:http://inko-lang.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Explicit type signatures for closure arguments allow bypassing the type checker

yorickpeterse opened this issue · comments

Please describe the bug

When using explicit type signatures for closure arguments, it's possible to specify type signatures that aren't compatible with what is expected, yet the compiler doesn't catch this.

Please list the exact steps necessary to reproduce the bug

Create test.inko with these contents:

class Thing {
  fn mut example(value: mut Array[Int]) {}
}

class async Main {
  fn async main {
    let a = [Thing()]

    a.iter.each(fn (thing: mut Thing) { thing.example([]) })
  }
}

When running inko check test.inko, a type error should be produced for the thing argument as the actual value is ref Thing (due to a.iter instead of a.iter_mut) and not mut Thing, yet the compiler considers this code to be valid.

Operating system

Fedora 40

Inko version

main

Rust version

1.70.0