swiftlang / swift-foundation

The Foundation project
Apache License 2.0
2.36k stars 150 forks source link

`StringProtocol.contains(_:)` returns false for empty string #891

Open yo1995 opened 3 weeks ago

yo1995 commented 3 weeks ago

Description

Please see the Swift forum post for details: https://forums.swift.org/t/nsstring-contains-returns-false-for-empty-string-argument/3949

It seems that the current implementation in Foundation has this problem, while the implementation in _StringProcessing doesn't.

// Without importing Foundation
"foo".contains("") // ⟹ true

import Foundation
"foo".contains("") // ⟹ false