Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicit type signatures for closure arguments allow bypassing the type checker #718

Open
yorickpeterse opened this issue Jun 3, 2024 · 0 comments
Labels
bug Defects, unintended behaviour, etc compiler Changes related to the compiler

Comments

@yorickpeterse
Copy link
Collaborator

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

@yorickpeterse yorickpeterse added bug Defects, unintended behaviour, etc compiler Changes related to the compiler labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Defects, unintended behaviour, etc compiler Changes related to the compiler
Projects
None yet
Development

No branches or pull requests

1 participant