swiftlang / swift-corelibs-foundation

The Foundation Project, providing core utilities, internationalization, and OS independence
swift.org
Apache License 2.0
5.27k stars 1.13k forks source link

[SR-15700] Set.intersection returns wrong other element instead of self #3184

Open swift-ci opened 2 years ago

swift-ci commented 2 years ago
Previous ID SR-15700
Radar None
Original Reporter racer1988 (JIRA User)
Type Bug

Attachment: Download

Environment Xcode 13.2.1 swift-driver version: 1.26.21 Apple Swift version 5.5.2 (swiftlang-1300.0.47.5 clang-1300.0.29.30) Target: x86_64-apple-macosx12.0
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation, Standard Library, swift | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 74ff9a9b4fa7fab1f518641db1695df7

Issue Description:

Due to https://github.com/apple/swift/commit/4e0c6f99b82f7a9a2ba5aecdde6151d16fada913

executing myself.intersection(other) returns other elements instead of myself if other.count is smaller or same size.

This create a big issue in case the comparison is not done on the entire object but the hash is calculated only from specific parts of the object (see a playground attached for demonstration)

myself.intersection(other) should always return only elements from the myself Set and never from other (as it does now)

https://github.com/apple/swift/commit/2e3e88cab8a395e3c6122f173bea3f13861d54b6

Might solve the issue, but it's really unclear to me if this one was released or not.

@lorentey could you let me know if your change is fixing this issue and the scheduled release?

We tested in Xcode 13.2.1 with Swift 5.5.2 and the bug is still reproducible

CC matthiaskmt (JIRA User)

swift-ci commented 2 years ago

Comment by Marco Pappalardo (JIRA)

git tag --contains 2e3e88cab8a395e3c6122f173bea3f13861d54b6

returns

swift-DEVELOPMENT-SNAPSHOT-2021-11-10-a
swift-DEVELOPMENT-SNAPSHOT-2021-11-11-a
swift-DEVELOPMENT-SNAPSHOT-2021-11-12-a
swift-DEVELOPMENT-SNAPSHOT-2021-11-15-a
swift-DEVELOPMENT-SNAPSHOT-2021-11-19-a
swift-DEVELOPMENT-SNAPSHOT-2021-11-20-a
swift-DEVELOPMENT-SNAPSHOT-2021-12-02-a
swift-DEVELOPMENT-SNAPSHOT-2021-12-04-a
swift-DEVELOPMENT-SNAPSHOT-2021-12-06-a
swift-DEVELOPMENT-SNAPSHOT-2021-12-23-a
swift-DEVELOPMENT-SNAPSHOT-2022-01-06-a 

so it seems to me the change has not been released yet?

swift-ci commented 2 years ago

Comment by Marco Pappalardo (JIRA)

@belkadan I saw you parsing other tickets I opened.. so wanted to know how to up this.

glessard commented 2 years ago

The commit you're looking for is part of the Swift 5.6 release.

Can you reproduce this issue with Xcode 13.3?