Skip to content

collection_methods_unrelated_type does not warn about null keys. #57101

@fuzzybinary

Description

@fuzzybinary

Describe the issue
According to #58427, collection_methods_unrelated_type should warn about using null as a key to a non-nullable collection. However, the following code does not generate the lint:

final v = <String, String>{ “somekey” : “somevalue” };
final nv = v[null];

If this is expected, I propose another lint that will warn about indexing into collections with non-null keys with potentially null values.

To Reproduce

The following code:

final v = <String, String>{ “somekey” : “somevalue” };
final nv = v[null];

Expected behavior
Warn on line 2 about null being used to on a map with non-null keys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-false-negativeIssues related to lint rules that fail to report a problem.linter-set-coretype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions