Skip to content

Fix Data.WritingOptions SetAlgebra semantics violations#1822

Merged
jmschonfeld merged 2 commits intoswiftlang:mainfrom
jmschonfeld:data-writingoptions-semantics
Mar 16, 2026
Merged

Fix Data.WritingOptions SetAlgebra semantics violations#1822
jmschonfeld merged 2 commits intoswiftlang:mainfrom
jmschonfeld:data-writingoptions-semantics

Conversation

@jmschonfeld
Copy link
Copy Markdown
Contributor

Fixes incorrect semantics of Data.WritingOptions SetAlgebra operations

Motivation:

Data.WritingOptions does not follow the semantic requirements of SetAlgebra. Notably, the file protection part is an enum value (zero or one may be selected, not multiple) and so the existing bit mask-based arithmetic on these values is not correct. This causes unexpected results when using operations like .contains

Modifications:

Add AEIC versions of each broken SetAlgebra function providing better behavior when possible

Result:

Data.WritingOptions now behaves as you'd expect and abides by all SetAlgebra semantic constraints. The only slightly problematic behavior remaining is from formUnion - it is not possible to form a union between two option sets that both contain file protection parts, so we only keep one of them.

Testing:

Added new unit tests that run exhaustive conformance validation tests as well as targeted tests of common expected use patterns.

@jmschonfeld jmschonfeld requested a review from kperryua March 16, 2026 18:16
@jmschonfeld jmschonfeld requested a review from a team as a code owner March 16, 2026 18:16
@jmschonfeld
Copy link
Copy Markdown
Contributor Author

@swift-ci please test

@jmschonfeld jmschonfeld merged commit 62fb47c into swiftlang:main Mar 16, 2026
22 checks passed
@jmschonfeld jmschonfeld deleted the data-writingoptions-semantics branch March 16, 2026 21:19
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