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

Fix Swift 6 concurrency error (on Linux) #127

Merged
merged 1 commit into from
Aug 2, 2024

Conversation

finestructure
Copy link
Contributor

@finestructure finestructure commented Jul 25, 2024

This fixes a Swift 6 compile error (on Linux):

/host/Sources/CustomDump/Conformances/Foundation.swift:50:24: error: static property 'formatter' is not concurrency-safe because non-'Sendable' type 'DateFormatter' may have shared mutable state
 48 |     }
 49 | 
 50 |     private static let formatter: DateFormatter = {
    |                        `- error: static property 'formatter' is not concurrency-safe because non-'Sendable' type 'DateFormatter' may have shared mutable state
 51 |       let formatter = DateFormatter()
 52 |       formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"

See also: SwiftPackageIndex/SwiftPackageIndex-Server#3115 (comment)

@finestructure finestructure changed the title Fix Swift 6 concurrency error Fix Swift 6 concurrency error (on Linux) Jul 25, 2024
Copy link
Member

@stephencelis stephencelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member

@stephencelis stephencelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again! Sorry we lost track of this!

@finestructure
Copy link
Contributor Author

finestructure commented Aug 2, 2024

I believe this fix might be superfluous thanks to the new Swift Foundation:

❯ docker pull swiftlang/swift:nightly-6.0-jammy
nightly-6.0-jammy: Pulling from swiftlang/swift
4ce000a43472: Already exists 
2f93d687a70b: Pull complete 
4f4fb700ef54: Pull complete 
989dc8e70c12: Pull complete 
04d2dc059ad6: Pull complete 
9cc74bbadbae: Pull complete 
Digest: sha256:046fec375e24ecf96a1ed9794e01045bcf8a86fb465e374536230e0b266b7551
Status: Downloaded newer image for swiftlang/swift:nightly-6.0-jammy
docker.io/swiftlang/swift:nightly-6.0-jammy

What's next:
    View a summary of image vulnerabilities and recommendations → docker scout quickview swiftlang/swift:nightly-6.0-jammy
~/D/swift-custom-dump on main took 1m37s 
❯ dsh swiftlang/swift@sha256:046fec375e24ecf96a1ed9794e01045bcf8a86fb465e374536230e0b266b7551
# bash
################################################################
#                                                              #
# Swift Nightly Docker Image                                   #
# Tag: swift-6.0-DEVELOPMENT-SNAPSHOT-2024-08-01-a             #
#                                                              #
################################################################
root@docker-desktop:/host# swift build
warning: 'xctest-dynamic-overlay': /host/.build/checkouts/xctest-dynamic-overlay/[email protected]:5:15: warning: 'init(name:defaultLocalization:platforms:pkgConfig:providers:products:dependencies:targets:swiftLanguageVersions:cLanguageStandard:cxxLanguageStandard:)' is deprecated: replaced by 'init(name:defaultLocalization:platforms:pkgConfig:providers:products:dependencies:targets:swiftLanguageModes:cLanguageStandard:cxxLanguageStandard:)'
 3 | import PackageDescription
 4 | 
 5 | let package = Package(
   |               |- warning: 'init(name:defaultLocalization:platforms:pkgConfig:providers:products:dependencies:targets:swiftLanguageVersions:cLanguageStandard:cxxLanguageStandard:)' is deprecated: replaced by 'init(name:defaultLocalization:platforms:pkgConfig:providers:products:dependencies:targets:swiftLanguageModes:cLanguageStandard:cxxLanguageStandard:)'
   |               `- note: use 'init(name:defaultLocalization:platforms:pkgConfig:providers:products:dependencies:targets:swiftLanguageModes:cLanguageStandard:cxxLanguageStandard:)' instead
 6 |   name: "xctest-dynamic-overlay",
 7 |   platforms: [
Building for debugging...
[56/56] Compiling CustomDump UserNotificationsUI.swift
Build complete! (3.08s)
root@docker-desktop:/host# 
root@docker-desktop:/host# git rev-parse @
aec6a73f5c1dc1f1be4f61888094b95cf995d973

(dsh == docker run --rm -it -v $PWD:/host -w /host --network="host" --entrypoint sh $argv;)

@finestructure
Copy link
Contributor Author

Using the computed value should definitely be safer though, as I'm not sure if Johannes advices changes with the new Foundation.

@stephencelis
Copy link
Member

Yeah I think it's probably harmless to have a computed var here given this is a debug tool.

@stephencelis stephencelis merged commit 82645ec into pointfreeco:main Aug 2, 2024
5 checks passed
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 this pull request may close these issues.

2 participants