-
Notifications
You must be signed in to change notification settings - Fork 622
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
redundanttype rule is not smart enough #1637
Comments
@elenzil IIRC this was a deliberate choice. Expressions in Swift (especially chains of operators like +) can exponentially increase compile times, and the common workaround is to add an explicit type (which you wouldn't then want SwiftFormat to remove). I don't actually recall why the separate redundantParens rule isn't applied in this case, which would then also cause the explicit type to be removed. That might be a bug or it may have been a deliberate choice for similar reasons (I should probably document these decisions better). |
Hello!
with swiftformat version 0.52.8, using a command line like this:
swiftformat --redundanttype inferred --swiftversion 5.9 .
the following code:
is reformatted to this:
I would like it to be reformatted to this:
Similar behavior if assigning to the value of a function, etc.
In actual code I work with, this catches a fairly small percentage of redundant type declarations.
Note, it will strip the type from the
a
declaration if the parens are removed:becomes
The text was updated successfully, but these errors were encountered: