Skip to content

Linter allows compare different enums #58653

Closed
@westito

Description

@westito

Describe the issue
Linter allows comparing different enums, despite unrelated_type_equality_checks enabled

To Reproduce

enum FilterGroupBy { date, competitions }
enum FilterMatchSelection { allMatches, onlyFavorites }

FilterGroupBy groupBy = FilterGroupBy.date;
FilterMatchSelection matchSelection = FilterMatchSelection.allMatches;

// No linter error
if (groupBy == FilterMatchSelection.onlyFavorites) {
}

// Comparing variables allowed either
if (groupBy == matchSelection) {
}

// Linter: Equality operator `==` invocation with references of unrelated types.
if (groupBy == 0) {
}

Expected behavior
Linter shows unrelated types error

Version
Dart SDK version: 2.16.0 (stable) (Mon Jan 31 15:28:59 2022 +0100) on "macos_x64"

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestdevexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-negativeIssues related to lint rules that fail to report a problem.type-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