Skip to content

dart format produce invalid code #1404

@nielsenko

Description

@nielsenko

Try formatting:

int weird(Object o) {
  return switch (o) {
    int i => i, // evil comment
    _ => 42
  };
}

produces:

int weird(Object o) {
  return switch (o) { int i => i, // evil comment _ => 42 };
}

which is obviously not valid Dart.

Reproduced with both Dart 3.3.0 and 3.4.0-157.0.dev, and 3.0.0 for that matter.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions