Skip to content

Commit d71ae84

Browse files
committed
Fix overly strict sendability checks
Some changes introduced in 0.18.0 resulted in checks for sendable values/calls being overly strict. For example, it was no longer allow to return a `uni ref T` value through methods such as Array.get even when this poses no problems. In addition, the checks for sendable output types didn't handle generic types properly resulting in them not being considered sendable. This commit fixes both these issues and adds some tests such that we can hopefully catch future regressions. Changelog: changed
1 parent 4738b81 commit d71ae84

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
type A {}
2+
3+
type B {
4+
let @a: A
5+
let @b: ref A
6+
7+
fn take(values: Array[uni B]) {}
8+
}
9+
10+
fn borrow(value: ref B) {}
11+
12+
fn example1(value: uni B) {
13+
[value].get(0)
14+
}
15+
16+
fn example2(value: uni B) {
17+
borrow([value].get(0))
18+
}
19+
20+
fn example3(value: uni B) {
21+
let values = [value]
22+
23+
values.get(0).take(values)
24+
}
25+
26+
# return_uni_borrow.inko:17:10 error(invalid-type): expected a value of type 'ref B', found 'uni ref B'
27+
# return_uni_borrow.inko:23:22 error(invalid-type): the receiver of this call requires sendable arguments, but 'Array[uni B]' isn't sendable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
type MyMap[K, V] {
2+
let @keys: Array[K]
3+
let @values: Array[V]
4+
5+
fn clone -> Self {
6+
MyMap(keys: [], values: [])
7+
}
8+
}
9+
10+
fn example1 {
11+
let a = recover MyMap(keys: ['foo'], values: ['bar'])
12+
13+
a.clone
14+
}
15+
16+
fn example2 {
17+
let a = recover MyMap(keys: ['foo'], values: ['bar'])
18+
let b = recover a.clone
19+
20+
b.invalid
21+
}
22+
23+
# sendable_generic_type.inko:20:3 error(invalid-symbol): the method 'invalid' isn't defined for type 'uni MyMap[String, String]'

0 commit comments

Comments
 (0)