Skip to content

Lint that flags uses of Map, Set, or List with keys outside the domain of the type #58604

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

Closed
Hixie opened this issue Jan 1, 2022 · 2 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.

Comments

@Hixie
Copy link
Contributor

Hixie commented Jan 1, 2022

According to #48030, it's intentional that you can do things like:

  Map<String, int> foo = {};
  // ...
  print(foo[2]); // prints null, since foo cannot possibly contain an entry with key 2

It would be nice if that tripped a lint to warn you that you're doing something almost certainly invalid.

This would apply to all the methods and operators on the container classes that are defined to take Object? instead of K.

@parlough
Copy link
Member

parlough commented Jan 1, 2022

Related: #57844 and #58427

@srawlins
Copy link
Member

Duplicate of #58427 and #57434 and #57844

@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead.
Projects
None yet
Development

No branches or pull requests

4 participants