Call/return type checking
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
When executing a `CALL`, the callee receives a pointer to a byte array, which isn't type-safe. When executing `RETURN`, the caller receives a pointer to a byte array, which also isn't type-safe.
The current way to resolve this is to generate bytecode that does type-checking at runtime, in order to guarantee the byte arrays can be considered of the right type. As an example, if the underlying value is a `byte[32]` (i.e. a hash digest), then the untyped byte array should have a length of exactly 32. No further checks are necessary for this type.
One issue that arises here is the possibility of aliasing, especially with collections like `Vec`. If the backing arrays of two `Vec` variables are actually the same, then all guarantees of the borrow checker are gone. Of course, every returned `Vec` could be considered as aliased, but that seems like it would be not-great for usability. It might be costly to ensure there is no aliasing at runtime, but maybe not?
Another way of resolving this would be to add an allocator to the VM itself, but that's something we ideally want to avoid.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.