"Remove dead code" quick fix doesn't properly handle a dead body of an "if" statement #60536
Labels
area-devexp
For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.
devexp-quick-fix
Issues with analysis server (quick) fixes
devexp-server
Issues related to some aspect of the analysis server
P2
A bug or feature request we're likely to work on
Starting with the following file:
Place the cursor over the statement
print('Should never happen');
(which should be grayed out, since it is dead code). Select the "Remove dead code" quick fix.Expected result: the whole
if
statement should be deleted, resulting in:Observed result: just the dead statement is deleted, resulting in:
This is particularly unfortunate because it constitutes a behavioral change: after the dead code removal,
print('Should always happen');
will not execute.I think this issue is particularly important because when the
sound flow analysis
language feature is enabled, a lot of code will start getting flagged as dead code, for example:If we don't address this, and a user upgrades to a language version that includes the
sound flow analysis
feature, they might try to use "dart fix" to automatically clean up the resulting dead code, and get a really unexpected result.The text was updated successfully, but these errors were encountered: