Open MichaelRFairhurst opened 7 years ago
Yeah the dead code checking in binary logical expressions is very limited. In particular, the _getConstantBooleanValue
method has a big chunk of text commented out with no explanation other than:
Don't consider situations where we could evaluate to a constant boolean expression with the ConstantVisitor
But why not? Performance? I'm not sure that the/a ConstantVisitor would reconcile this, but I shouldn't think it would be hard...
In addition to number literals, boolean literals should also be included in this request. Basically https://github.com/dart-lang/sdk/issues/3511:
while (true) {
if (false) break;
}
In trivial cases its pretty easy to see what atually is/isn't dead code, in part because of the partial warning. But in more complicated cases, it may create confusion that the "dead code" section does not highlight all of the dead code (in mixtures of dead and live code, etc).
repro.dart:
What happens:
1 == 2
is highlighted as dead code because its afterfalse &&
so won't do anything.What I expect to happen:
1 == 2 && 3 == 4
is highlighted, because that entire section is dead, not just the1 == 2
.