We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1ed2f62 commit f2985d5Copy full SHA for f2985d5
test/Constraints/sr10757.swift
@@ -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