Skip to content

Commit f2985d5

Browse files
committed
[TypeChecker] NFC: Add a test-case for SR-10757 (rdar://72770327)
1 parent 1ed2f62 commit f2985d5

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/Constraints/sr10757.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
// SR-10757
4+
5+
struct Parser<A> {
6+
let run: (inout Substring) -> A?
7+
8+
func map<B>(_ f: @escaping (A) -> B) -> Parser<B> {
9+
return Parser<B> { input in
10+
self.run(&input).map(f)
11+
}
12+
}
13+
}
14+
15+
let char = Parser<Character> { str in
16+
guard let match = str.first else { return nil }
17+
str.removeFirst()
18+
return match
19+
}
20+
21+
let northSouth = char.map {
22+
$0 == "N"
23+
? 1.0
24+
: $0 == "S" ? -1 : nil // Ok
25+
}

0 commit comments

Comments
 (0)