Skip to content

[cfe] Type void is allowed in []= operator #57071

@sgrekhov

Description

@sgrekhov

The code below produce no issues in the analyzer but errors in CFE.

main() {
  Map<void, int> m1 = <void, int>{};
  void key = 0;
  m1[key] = 1; // Error: This expression has type 'void' and can't be used.

  Map<int, void> m2 = <int, void>{};
  void value = 0;
  m2[2] = value; // Error: This expression has type 'void' and can't be used.
}

Acording to the specification key and value of type void in the []= operator are both allowed.

See also #57070.

Metadata

Metadata

Labels

area-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.cfe-dysfunctionalitiesIssues for the CFE not behaving as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions