dart-lang / sdk

The Dart SDK, including the VM, dart2js, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
9.94k stars 1.53k forks source link

`RemoveUnusedLocalVariable` fixer removes whole expression function body #51032

Open oprypin opened 1 year ago

oprypin commented 1 year ago

Example code:

void main() {
  var foo = false;
  (() => foo = true)();
}

Suggested fix for unused_local_variable produces invalid syntax:

void main() {
  (())();
}
asashour commented 1 year ago

https://dart-review.googlesource.com/c/sdk/+/279342