linter icon indicating copy to clipboard operation
linter copied to clipboard

Linter allows compare different enums

Open westito opened this issue 3 years ago • 0 comments

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"

westito avatar Feb 05 '22 11:02 westito