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

Generated @available has trailing whitespace #97

Closed
niklassaers opened this issue Jun 13, 2024 · 5 comments · Fixed by #98
Closed

Generated @available has trailing whitespace #97

niklassaers opened this issue Jun 13, 2024 · 5 comments · Fixed by #98
Labels
bug Something isn't working

Comments

@niklassaers
Copy link

Hi,
I'm moving my project towards Swift 6, and Swift 6 is treating trailing space after @available as an error (before that it was a warning)

Example in my generated code:
@available (*, deprecated, message: "Use `String.LocationAccess.notNowButton` instead. This property will be removed in the future.")

This gives the error:
Extraneous whitespace between attribute name and '('; this is an error in the Swift 6 language mode

@liamnichols liamnichols added bug Something isn't working labels Jun 13, 2024
@liamnichols
Copy link
Owner

Thanks for reporting this! I didn't think much of it at first and TIL that it's an error in Swift 6!

I think that the issue actually comes from swift-syntax since I run the generated code through it's formatter.

When I get a chance, I'll confirm and see if the issue has been addressed there. If we need to wait until September for a patch though, I'll figure out a workaround 👍

@niklassaers
Copy link
Author

niklassaers commented Jun 14, 2024

Thanks for explaining where it comes from. I pointed the build at the swift-syntax main branch instead of the pinned version and it seems to be resolved there. Here's the output from two of the tests included in xcstrings-tool:

     /// Creates a text view that displays a localized string defined in the ‘Localizable‘ strings table.
     public init(localizable: String.Localizable) {
−        if #available (macOS 13, iOS 16, tvOS 16, watchOS 9, *) {
+        if #available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) {
             self.init(LocalizedStringResource(localizable: localizable))
             return
         }

and

         /// %lld: People liked %lld posts
         /// ```
−        @available (*, deprecated, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
+        @available(*, deprecated, message: "Use `String.Localizable.mySubstitute(_:count:)` instead. This method will be removed in the future.")
         public func mySubstitute(_ arg1: Int, count arg2: Int) -> LocalizedStringResource {
             LocalizedStringResource(localizable: .mySubstitute(arg1, count: arg2))
         }

@liamnichols
Copy link
Owner

Thanks for conforming this! Since SwiftSyntax 600.0.0 isn't going to be tagged and released until September (I assume), i'm going to push up a patch that works with older versions in the meantime.

@liamnichols
Copy link
Owner

Thanks for reporting this @niklassaers, it was resolved in 0.5.1 which has just been released 🙏

@niklassaers
Copy link
Author

Awesome, thank you so much :-)

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

Successfully merging a pull request may close this issue.

2 participants