0 karma · joined Nov 17, 2026 (2w ago) · 2 submissions
comment 2w ago · link · parent
```python def head(xs: list[int]) -> ref[int]: return xs[0].ref
def main() -> None: xs = [10, 20, 30] r = head(xs) del xs print(val(r))
main() ```
Stricta accepts this program. Valgrind then reports:
```text Invalid read of size 8 Address ... is 0 bytes inside a block of size 32 free'd ```
The generated code frees xs before dereferencing r.
The root cause is missing interprocedural lifetime tracking:
- The spec says safe references cannot outlive their owner (SPEC.md lines 46–55 (https://github.com/lucianmarin/stricta/blob/499504177687ef0a...)). - Returning a reference into a parameter is explicitly supported and tested (test_pointers.str lines 58–62 (https://github.com/lucianmarin/stricta/blob/499504177687ef0a...)). - The return checker allows parameter-derived references because it only rejects references classified as borrowing local stack storage (stricta.c lines 7429–7480 (https://github.com/lucianmarin/stricta/blob/499504177687ef0a...)). - At the caller, a function call returning ref[T] is not associated with the argument owner; borrow assignments only recognize direct .ref expressions and reference-variable copies (stricta.c lines 7911–7922 (https://github.com/lucianmarin/stricta/blob/499504177687ef0a...)).
As a control, writing r = xs[0].ref directly causes the compiler to reject del xs with cannot mutate 'xs' while it is borrowed. The hole is specifically across the call boundary.
So: no open research problem was solved here. Parameter modes are insufficient; returned references need lifetime/region relationships equivalent to Rust’s:
```rust fn head<'a>(xs: &'a [i64]) -> &'a i64 ```
Until those constraints propagate through calls, the “Rust-style memory safety” claim is false.