You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an inline type contains a uni T value, it's possible to borrow the inline type and still access the uni T (through e.g. a uni ref T) even after the uni T is sent to another process. For example:
type async Unsound {
fn async unsound(value: uni Foo) {}
}
type Foo {
let @value: Int
}
type inline Bar {
let @value: uni Foo
}
type async Main {
fn async main {
let a = Bar(recover Foo(42))
let b = ref a
match a {
case { @value = v } -> Unsound().unsound(v)
}
# we can continue to use `uni Foo` here through `b.value`
}
}
The issue here is that inline types being copied results in an alias to the uni T value.
A potential option is to disallow borrowing of inline types if they contain a uni T value, though this may prove too heavy handed.
Operating system
Fedora
Inko version
main
The text was updated successfully, but these errors were encountered:
Not allowing borrows of inline types containing uni T values won't work, as this effectively prohibits calling methods on such inline types (as this borrows the receiver).
I think we can handle this by extending the type verification done when lowering to MIR: if we encounter a mut T or ref T where T contains a uni V, then we produce an error as using such a borrow isn't safe.
A variation is that we allow such borrows, but restrict access to methods that happen to borrow the field(s) in question. I'm not sure yet which approach is best.
Please describe the bug
When an
inline
type contains auni T
value, it's possible to borrow theinline
type and still access theuni T
(through e.g. auni ref T
) even after theuni T
is sent to another process. For example:The issue here is that
inline
types being copied results in an alias to theuni T
value.A potential option is to disallow borrowing of
inline
types if they contain auni T
value, though this may prove too heavy handed.Operating system
Fedora
Inko version
main
The text was updated successfully, but these errors were encountered: