Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invariant_booleans false positive when using assignment operator (like +=) #57853

Closed
ghost opened this issue Dec 20, 2018 · 3 comments
Closed
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive P4 type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@ghost
Copy link

ghost commented Dec 20, 2018

@jfphilbin commented on Dec 17, 2018, 9:54 AM UTC:

In Dart SDK Version2.2.0-dev.1.1 on Windows 10, the following code:

void main() {
  foo('****', 0, 5);
}

int foo(int start, int end, [int x = 0]) {
  var s = 0, index = start;
  if ((index += 2) < end) {
    if ((index += 2) < end) {  // Info here
      if (x == null) s = 1;
    }
 }
 return s;
}

Generates the following Analyzer Info:

info: Conditions should not unconditionally evaluate to `true` or to `false`. verify: (index += 2) < end. 
    (invariant_booleans at [core] bin\bug.dart:15)

Which I think is incorrect.

This issue was moved by stereotype441 from dart-lang/sdk#35429.

@stereotype441 stereotype441 added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) linter-false-positive labels Dec 20, 2018
@stereotype441
Copy link
Member

@pq FYI

@srawlins
Copy link
Member

Another invariant_booleans false positive. This time the issue is +=.

@srawlins
Copy link
Member

We've deprecated invariant_booleans and will not be fixing correctness bugs going forward.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-false-positive P4 type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants