Skip to content

Destructuring with explicit type of nullable record is a parsing error. #52439

Closed
@water-mizuu

Description

@water-mizuu

As said in the title, the simplified code below is not accepted.

typedef Index = (int y, int x);

void main() {
  var (int y, int x) = (1, 3);
  var (bool reset, (int, int, int)? color) = switch ((y, x)) {
    Index ind when ind != ind => (true, (0, 128, 128)),
    _ => (false, null),
  };
}

Removing the question mark parses correctly, or by creating a type alias works as well.

typedef Index = (int y, int x);
typedef Color = (int r, int g, int b);

void main() {
  var (int y, int x) = (1, 3);
  var (bool reset, Color? color) = switch ((y, x)) {
    Index ind when ind != ind => (true, (0, 128, 128)),
    _ => (false, null),
  };
}

Metadata

Metadata

Assignees

Labels

front-end-fastalegacy-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