gleam-lang / gleam

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

Replace use detection with a call graph #2634

Open giacomocavalieri opened 8 months ago

giacomocavalieri commented 8 months ago

I noticed that a private recursive function is not marked as unused. For example this one raises no warnings:

fn wobble() {
  wobble()
}
lpil commented 8 months ago

Yup! The current system isn't very good. I've been wanting to replace it with a proper call graph for ages but I've not got round to that yet.

I've not made an issue for it either, so let's use this one.

giacomocavalieri commented 8 months ago

Cool! Do you already have an idea on how to do that? I'm really curious to learn how that's going to be implemented 👀

lpil commented 8 months ago

Closes https://github.com/gleam-lang/gleam/issues/2579

giacomocavalieri commented 1 week ago

In this test the unused variable should be marked as unused!

pub fn loop(cond: Bool, unused: Int) {
  case cond {
    True -> loop(False, unused)
    False -> 1
  }
}