Skip to content

The analyzer should parse asserts in initializer lists. #27142

Closed
@lrhn

Description

@lrhn

See #27141 for details.

The analyzer should accept an assert "expression" (like an assert statement without a trailing ;) as an element in initializer lists.

To enable: add the flag enableAssertInitializer in the language section of the .analysis_options file. Here is an example:

analyzer:
  language:
    enableAssertInitializer: true

As an initial implementation, the analyzer can skip analyzing the assertion completely.

It would be great if it could also evaluate any assert in a const context (in an initializer of a const constructor which is used to create a compile-time constant value). This would enable earlier errors for the team that is experimenting with the feature.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work oncustomer-flutterlegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions