Skip to content

prefer_conditional_assignment false positive on complex statements #57859

Closed
@srawlins

Description

@srawlins

Take the following code:

class Person {
  A a;
  A b;

  void f() {
    if (a.i == null) {
      // LINT
      b.i = 7;
    }
  }
}

class A {
  int i;
}

This code reports an error at the LINT line, "Prefer using ??= over testing for null," because it does not take into account that a.i is not equal to b.i.

(Same cause as #57855 and #57858)

Metadata

Metadata

Assignees

Labels

devexp-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

      Participants

      @srawlins@devoncarew

      Issue actions

        prefer_conditional_assignment false positive on complex statements · Issue #57859 · dart-lang/sdk