Skip to content

ISO8601DateFormatter.Options should have immutable static properties #4703

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

Closed
fumoboy007 opened this issue Feb 17, 2023 · 0 comments · Fixed by #4706
Closed

ISO8601DateFormatter.Options should have immutable static properties #4703

fumoboy007 opened this issue Feb 17, 2023 · 0 comments · Fixed by #4706

Comments

@fumoboy007
Copy link
Contributor

fumoboy007 commented Feb 17, 2023

ISO8601DateFormatter.Options 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 added a commit to fumoboy007/swift-corelibs-foundation that referenced this issue Feb 19, 2023
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 added a commit to fumoboy007/swift-corelibs-foundation that referenced this issue Feb 19, 2023
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
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 a pull request may close this issue.

1 participant