Skip to content

Preserving user-authored line breaks produces non-deterministic output for equivalent syntax trees #638

Description

@c1rcle

While I do agree with the points raised in #547, I'm not a fan of the approach that was ultimately chosen. Preserving user-authored line breaks inside lambdas violates the deterministic premise this formatter was arguably built upon. The most appealing principle for me was that any equivalent input syntax tree would always result in the same formatted output (barring any additional newlines in function bodies). This is not the case anymore, as developers may influence the formatting result in lambdas, which aren't only used for DSLs.

Could this have been approached differently? How about wrapping the outer lambda body to a new line if it contains a nested lambda on the very same line? To be clear, I'm not suggesting that "preserve user-authored line breaks" should be completely removed or replaced - I just don't think it should have been made the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatting-discussionsDiscussions about how formatting should look like, when there's no clear consensus.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions