Skip to content

Why is using a wrongly typed index into a Map not an error but just a warning Β #57098

@escamoteur

Description

@escamoteur

I got bitten by this here

image

_imageCache is defined

  final Map<ReactionType, ui.Image> _imageCache = {};

where ReatcionType is an enum.
The warning says: The argument type 'String' isn't related to 'ReactionType'

even with

analyzer:
  language:
    # strict-casts: true
    # strict-inference: true

it stays a warning that throws an exception at runtime. I think this should always be treated as an error. Which use case would make sense to allow code with this to compile?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-core-librarySDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.library-coretype-questionA question about expected behavior or functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions