You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for _ in 1... |x| {/* ... */}
Int.random(in:−10...−1)
Run SwiftFormat once and the operators become conjoined, failing to compile:
for _ in 1...|x| {/* ... */}
Int.random(in:−10...−1)
Run SwiftFormat again and the spaces are restored, but in the wrong places—it’s still broken:
for _ in 1...| x| {/* ... */}
Int.random(in:−10...−1)
I would expect range operators to be spaced with the same uniformity as every other infix operator, but if the scrunched variant is desired, then it should at least be restricted to the situations where it is actually valid code.
The text was updated successfully, but these errors were encountered:
The original PR didn't handle that case, because it only considered following tokens that were `prefixOperator`s, whereas the case above is `prefixPeriod` because it's not "technically" an operator in the case of implicit member references.
Arguably, a safer way to check this would be to simply check the previous and next characters to see if they're operator code points, but I don't really want to hardcode that list into the formatter—after all, the whole point of using the compiler's syntax parser is to have it do the work so we don't have to duplicate it.
@akyrtzi, maybe the syntax parser library could be extended to have generally useful utility functions, like "is this character an identifier character or operator character"?
Environment
swift-5.1-branch as of 2019‐11‐17
Additional Detail from JIRA
md5: 0ba030d617ad8d07c00151cd32d99a3e
Issue Description:
Start with this code:
Run SwiftFormat once and the operators become conjoined, failing to compile:
Run SwiftFormat again and the spaces are restored, but in the wrong places—it’s still broken:
I would expect range operators to be spaced with the same uniformity as every other infix operator, but if the scrunched variant is desired, then it should at least be restricted to the situations where it is actually valid code.
The text was updated successfully, but these errors were encountered: