File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Sources/_StringProcessing/Unicode Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,10 @@ extension String {
8787 var j = maxIndex ?? range. lowerBound
8888
8989 while j < range. upperBound, j <= i {
90- cache!. insert ( j)
90+ // Workaround for underlying issue in https://github.com/swiftlang/swift-experimental-string-processing/issues/818
91+ let ( inserted, _) = cache!. insert ( j)
92+ guard inserted else { return true }
93+
9194 j = _wordIndex ( after: j)
9295 }
9396
Original file line number Diff line number Diff line change @@ -1946,6 +1946,22 @@ extension RegexDSLTests {
19461946 XCTAssertEqual ( anyOutput [ 15 ] . value as? Int , 123 )
19471947 XCTAssertEqual ( anyOutput [ 16 ] . substring, " 456 " )
19481948 }
1949+
1950+ func testIssue818( ) throws {
1951+ // Original report from https://github.com/swiftlang/swift-experimental-string-processing/issues/818
1952+ let clip = " ‘example.com’ "
1953+ let clip2 = " \u{2060} \u{2018} \u{2060} \u{2060} example.com \u{2060} \u{2060} \u{2019} "
1954+ assert ( clip. unicodeScalars. elementsEqual ( clip2. unicodeScalars) )
1955+
1956+ let pattern = Regex {
1957+ Anchor . wordBoundary // line A
1958+ " example "
1959+ Anchor . wordBoundary // line B
1960+ }
1961+
1962+ XCTAssertNotNil ( clip. contains ( pattern) )
1963+ XCTAssertNotNil ( clip2. contains ( pattern) )
1964+ }
19491965}
19501966
19511967extension Unicode . Scalar {
You can’t perform that action at this time.
0 commit comments