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

Make ISO8601DateFormatter.Options static properties immutable #4706

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

fumoboy007
Copy link
Contributor

Fixes #4703.

ISO8601DateFormatter.Options currently uses var for its static properties. The properties should instead be declared using let to prevent accidental mutation and to let the compiler know that these properties are concurrency-safe.

Regarding the latter point, the following is an example error caused by this issue:

error: reference to static property 'withInternetDateTime' is not concurrency-safe because it involves shared mutable state

Fixes swiftlang#4703.

[`ISO8601DateFormatter.Options`](https://github.com/apple/swift-corelibs-foundation/blob/7504fdfa4529ac01b77ab83bfee51a5f06e3e6d1/Sources/Foundation/ISO8601DateFormatter.swift#L14) currently uses `var` for its static properties. The properties should instead be declared using `let` to prevent accidental mutation and to let the compiler know that these properties are concurrency-safe.

Regarding the latter point, the following is an example error caused by this issue:
> error: reference to static property 'withInternetDateTime' is not concurrency-safe because it involves shared mutable state
@fumoboy007
Copy link
Contributor Author

@parkera since you merged #998?

@YOCKOW
Copy link
Member

YOCKOW commented Mar 15, 2023

@swift-ci Please test

@YOCKOW
Copy link
Member

YOCKOW commented Mar 16, 2023

@swift-ci Please test Windows platform

@YOCKOW YOCKOW merged commit 01f6389 into swiftlang:main Mar 17, 2023
@fumoboy007 fumoboy007 deleted the patch-1 branch March 17, 2023 03:44
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.

ISO8601DateFormatter.Options should have immutable static properties
2 participants