Skip to content

Rewrite and fix OneVariableDeclarationPerLine. #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2020

Conversation

allevato
Copy link
Member

The old rule implementation assumed that if there were
multiple bindings in a single var decl, the last one
contained the type that should be applied to all of
them. The rules are actually more complex than that,
because they don't apply to bindings that have
initializer clauses (from which the type is inferred),
and they also allow multiple sequences of bindings in
the same decl (e.g., var a, b: Int, c, d: String).

This change also ensures proper handling of leading
comments (does not duplicate them) and that nested
declarations are transformed correctly.

Fixes SR-13051.

The old rule implementation assumed that if there were
multiple bindings in a single var decl, the last one
contained the type that should be applied to all of
them. The rules are actually more complex than that,
because they don't apply to bindings that have
initializer clauses (from which the type is inferred),
and they also allow multiple sequences of bindings in
the same decl (e.g., `var a, b: Int, c, d: String`).

This change also ensures proper handling of leading
comments (does not duplicate them) and that nested
declarations are transformed correctly.

Fixes SR-13051.
@allevato
Copy link
Member Author

cc @dylansturg

@allevato allevato merged commit 2b4364b into swiftlang:master Jun 29, 2020
@allevato allevato deleted the one-var-per-line-fixes branch June 29, 2020 18:30
aaditya-chandrasekhar pushed a commit to val-verde/swift-format that referenced this pull request May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants