Skip to content

Conversation

@giacomocavalieri
Copy link
Member

This PR adds unused warning for pure case expressions, blocks, pipelines, function expressions and function calls

So if the compiler can understand one of those is pure and unused a warning will be raised. For example:

fn main() {
  { 1 }
//^^^^^ Now this is reported as unused
  Nil
}
fn main() {
  fn(n) { n + 1 }(1)
//^^^^^^^^^^^^^^^^^^ Now this is reported as unused
  Nil
}
fn main() {
  case wibble {
    [] -> 0
    _ -> 1
  }
//^^^^^^^^^^^^^ Now this is reported as unused
  Nil
}

Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said last time, we should not be spending any more time on the current dead code detection. It's flawed by design.

I'm happy to merge this, but with all the work we've spent on these PRs we could have replaced it with proper dead code detection.

@lpil lpil marked this pull request as draft November 19, 2024 14:56
@giacomocavalieri giacomocavalieri force-pushed the unused-fn-expr branch 2 times, most recently from 66ccd06 to abeb513 Compare November 21, 2024 12:02
@giacomocavalieri giacomocavalieri marked this pull request as ready for review November 21, 2024 12:27
Copy link
Member

@lpil lpil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@lpil lpil merged commit bc4f5b5 into gleam-lang:main Nov 25, 2024
12 checks passed
@giacomocavalieri giacomocavalieri deleted the unused-fn-expr branch November 25, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants