Skip to content

CFE allows ! selector in constants but shouldn't #59800

@sgrekhov

Description

@sgrekhov

The below works well in VM but produces an error in the analyzer.

const answer = "42"!; // Analyzer error. Const variables must be initialized with a constant value.

main() {
  print(answer);
}

Constant expression allows ! selector, therefore, I believe, it's an analyzer issue.

@lrhn @eernstg please confirm.

Dart SDK version: 3.7.0-274.0.dev (dev) (Thu Dec 19 20:06:50 2024 -0800) on "windows_x64"

Metadata

Metadata

Labels

cfe-dysfunctionalitiesIssues for the CFE not behaving as intendedlegacy-area-front-endLegacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions