Skip to content

"@dart" comments do not affect language-versioned style changes #1762

@munificent

Description

@munificent

The formatter produces different formatting depending on the language version of what it's formatting. The big change is between 3.6 and 3.7 where 3.7 opts you in to the new "tall" formatter. But there are other language-versioned style changes since then. In particular, 3.8 makes a number of formatting changes which are all language versioned.

The formatter will correctly honor a @dart comment to choose between the <=3.6 "short" style and >=3.7 tall style. But it does not look at the @dart comment to decide which tall style you get. Instead, it only selects the short or tall style. Once tall style has been selected, the @dart comment is ignored and you get the style for the file's default language version.

Concretely, the formatter should leave this code alone:

// @dart=3.7
var variable =
    condition
        ? thenBranch // Comment to force split.
        : elseBranch;

But instead it changes it to the 3.8 style:

// @dart=3.7
var variable = condition
    ? thenBranch // Comment to force split.
    : elseBranch;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions