Skip to content

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

Open
@swift-ci

Description

@swift-ci
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 swiftlang/swift@4e0c6f9

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)

swiftlang/swift@2e3e88c

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)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions