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

[SR-14206] infix operator is not supported by swift-format #311

Closed
compnerd opened this issue Feb 13, 2021 · 1 comment · Fixed by #399
Closed

[SR-14206] infix operator is not supported by swift-format #311

compnerd opened this issue Feb 13, 2021 · 1 comment · Fixed by #399
Labels
bug Something isn't working swift-format

Comments

@compnerd
Copy link
Collaborator

Previous ID SR-14206
Radar None
Original Reporter @compnerd
Type Bug
Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Bug
Assignee None
Priority Medium

md5: 5d0082075fcdcdda5e068a5ebb0862e8

Issue Description:

Trying to format something like:

infix operator || : LogicalDisjunctionPrecedence, Bool

Causes swift-format to fail with:

error: file contains invalid or unrecognized Swift syntax.
@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@allevato
Copy link
Collaborator

This appears to parse correctly in main now with the new SwiftParser, but the formatting is less than ideal:

.build/debug/swift-format <<'EOF'
infix operator || : LogicalDisjunctionPrecedence, Bool
EOF

Output:

infix operator ||: LogicalDisjunctionPrecedence,Bool

We should leave a space between the operator and colon, and the type/protocol list after the precedence group is having its interior spaces removed (which makes sense, given the less-than-public nature of that feature).

allevato added a commit to allevato/swift-format that referenced this issue Sep 16, 2022
Also, add a space between the operator and the colon; it should
have always been there, for consistency with `func #OP# (...)`.

Fixes apple#311.
allevato added a commit to allevato/swift-format that referenced this issue Sep 16, 2022
Also, add a space between the operator and the colon; it should
have always been there, for consistency with `func #OP# (...)`.

Fixes apple#311.
allevato added a commit to allevato/swift-format that referenced this issue Sep 16, 2022
Also, add a space between the operator and the colon; it should
have always been there, for consistency with `func #OP# (...)`.

Fixes apple#311.
allevato added a commit to allevato/swift-format that referenced this issue Sep 16, 2022
Also, add a space between the operator and the colon; it should
have always been there, for consistency with `func #OP# (...)`.

Fixes apple#311.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working swift-format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants