Skip to content
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

Incorrect formatting for arguments following postfix #if #705

Closed
hamishknight opened this issue Mar 18, 2024 · 1 comment · Fixed by #729
Closed

Incorrect formatting for arguments following postfix #if #705

hamishknight opened this issue Mar 18, 2024 · 1 comment · Fixed by #729

Comments

@hamishknight
Copy link
Contributor

For e.g:

print(
    ""
    #if true
        .count
    #endif
    , 0
)

swift-format produces:

print(
  ""
    #if true
      .count
    #endif, 0
)

which the compiler rejects since the comma may not appear on the same line as the #endif.

rdar://124557891

@davidgreenaway
Copy link

For anyone affected, a workaround is to add end empty comment at the end of the #endif line, as follows:

print(
  ""
    #if true
      .count
    #endif //
    , 0
)

This will prevent swift-format from joining the lines together (and hence causing the file to no longer compile).

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 a pull request may close this issue.

2 participants