@@ -10,6 +10,7 @@ class Some[T](value: T) extends Option[T]
10
10
module None extends Option[nothing]
11
11
class Pair[A, B](x: A, y: B)
12
12
13
+ // All `add_n` functions should be inferred to have the same type.
13
14
14
15
fun add_1(x, y) =
15
16
if
@@ -95,25 +96,25 @@ fun add_4(x, y) =
95
96
:fixme
96
97
add_4(None, None)
97
98
//│ ╔══[ERROR] Name not found: add_4
98
- //│ ║ l.96 : add_4(None, None)
99
+ //│ ║ l.97 : add_4(None, None)
99
100
//│ ╙── ^^^^^
100
101
101
102
:fixme
102
103
add_4(Some(5), None)
103
104
//│ ╔══[ERROR] Name not found: add_4
104
- //│ ║ l.102 : add_4(Some(5), None)
105
+ //│ ║ l.103 : add_4(Some(5), None)
105
106
//│ ╙── ^^^^^
106
107
107
108
:fixme
108
109
add_4(None, Some(9))
109
110
//│ ╔══[ERROR] Name not found: add_4
110
- //│ ║ l.108 : add_4(None, Some(9))
111
+ //│ ║ l.109 : add_4(None, Some(9))
111
112
//│ ╙── ^^^^^
112
113
113
114
:fixme
114
115
add_4(Some(5), Some(9))
115
116
//│ ╔══[ERROR] Name not found: add_4
116
- //│ ║ l.114 : add_4(Some(5), Some(9))
117
+ //│ ║ l.115 : add_4(Some(5), Some(9))
117
118
//│ ╙── ^^^^^
118
119
119
120
@@ -158,6 +159,7 @@ add_6(Some(5), Some(9))
158
159
//│ = 14
159
160
160
161
162
+ // Functions from now on have a predicate `p` that can be used to add some preconditions.
161
163
162
164
163
165
fun add_6(p, x, y) =
@@ -169,15 +171,23 @@ fun add_6(p, x, y) =
169
171
y is None and x is None then 0
170
172
171
173
174
+ :expect 0
172
175
add_6((x) => true, None, None)
173
176
//│ = 0
174
177
178
+ :expect 42
175
179
add_6((x) => true, Some(5), None)
176
180
//│ = 42
177
181
182
+ :expect 5
183
+ add_6((x) => false, Some(5), None)
184
+ //│ = 5
185
+
186
+ :expect 9
178
187
add_6((x) => true, None, Some(9))
179
188
//│ = 9
180
189
190
+ :expect 14
181
191
add_6((x) => true, Some(5), Some(9))
182
192
//│ = 14
183
193
@@ -192,18 +202,23 @@ fun add_7(p, x, y) =
192
202
y is None and x is None then 0
193
203
194
204
205
+ :expect 0
195
206
add_7((x) => x > 0, None, None)
196
207
//│ = 0
197
208
209
+ :expect 5
198
210
add_7((x) => x > 0, Some(5), None)
199
211
//│ = 5
200
212
213
+ :expect 36
201
214
add_7((x) => x > 0, None, Some(9))
202
215
//│ = 36
203
216
217
+ :expect -9
204
218
add_7((x) => x > 0, None, Some(-9))
205
219
//│ = -9
206
220
221
+ :expect 14
207
222
add_7((x) => x > 0, Some(5), Some(9))
208
223
//│ = 14
209
224
@@ -218,21 +233,27 @@ fun add_8(p, x, y) =
218
233
y is None and x is None then 0
219
234
220
235
236
+ :expect 0
221
237
add_8((x) => x > 0, None, None)
222
238
//│ = 0
223
239
240
+ :expect 42
224
241
add_8((x) => true, Some(9), None)
225
242
//│ = 42
226
243
244
+ :expect 5
227
245
add_8((x) => x > 0, Some(5), None)
228
246
//│ = 5
229
247
248
+ :expect 36
230
249
add_8((x) => x > 0, None, Some(9))
231
250
//│ = 36
232
251
252
+ :expect -9
233
253
add_8((x) => x > 0, None, Some(-9))
234
254
//│ = -9
235
255
256
+ :expect 14
236
257
add_8((x) => x > 0, Some(5), Some(9))
237
258
//│ = 14
238
259
0 commit comments