Skip to content

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

Closed
@ghost

Description

@ghost

@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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-positivetype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions