Hacker News new | ask | show | jobs
by platinumrad 18 days ago
> Rust-Style Memory Safety (No GC / No ARC): Compile-time ownership and borrow checking with inferred BORROW / MUT_BORROW / MOVE parameter modes, non-lexical lifetimes (NLL), monomorphized deterministic @_drop_T / @_clone_T generation, compiler-lowered { i1, T } exception propagation, and runtime bounds traps—with zero garbage collection or reference counting overhead.

There is either a catch here or you(r LLM) has solved multiple open research problems.

1 comments

Get the code and ask your LLM if it did, otherwise provide an edge case to be fixed.
No need for that, I checked it, it's a good little language but not near Rust or Nim The way you designed bound checking, parameter inferences is more a source of bugs than anything I didn't see support for advanced closures and how it's integrated with the borrow checker (since you claim not having lifetimes, there are tons of unanswered questions in your thing)

Your desing of generic instantiation is just a compile time pit. You don't constraint type so you need to check the body of every instance

You have NLL yeah, but not partial borrows nor the capacity for a proc to return one of it's parameters (the famous example

```rs

fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { if x.len() > y.len() { x } else { y } }

```

since you don't have lifetimes, either you refuse this case or it's a bug if you do a copy then your language asks it's user to use value semantics

But if your language mostly push users to value semantics (a.k.a copying tons of things) then why all the borrow stuff ? If there is no lifetime how is one suposed to store references ? why is there a ref, ref_mut type ?

Those are overly convoluted choices for a value based language So it's a bit of an incoherence

Next there is the way you handle indexing your spec state that undecided index access generate stricta_bounds_fail, but this function just output an error and exit the process, it doesn't insert a runtime check

So undecided index access act as nuke in the codebase, the users is not even aware that one of it's access is undecided, and when he expect it the less he just get the process stopped, no exceptions, just a crash

Then you don't even correctly handle cyclic data type structure, you defined in the codebase an arbitrary depth of 16 instead of checking type cycle (and what you stated in your spec just worked auto referencing types like type A with a field of type A again

Finally I don't understand whant Stricta is supposed to achieve. Is it a stricter python ? If it's the case then why doesn't talk about compatibility ? why does it diverge from python on the semantic side ? If it's just python like... then why the pythonish choices ? like hardcoded python types and OOP ?

The concern is justified. At commit 4995041, Stricta’s borrow checker is unsound across function returns.

```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.