Issue #2531: A proved parent link compiles to a reference or a weak handle and does not leak

Open and answer this issue on GitHub.

compiler, ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments

Part of #1649 Part of #1626 After #1649 Needs #1648 Needs #1647

What it is

Step 4 of ADR-shared-handle-cycles-1, second part: the lowering of a back field that #1649 proved and classified. ADR-shared-handle-cycles-1 D3: F1 is a non-owning reference, unchecked, used where the compiler proves the target outlives the holder; F2 is a weak handle that reads null once the target is gone, used only for optional fields (T?). Lowering F2 follows ADR-312 (lowered types): std::rc::Weak for SharedMut, std::sync::Weak for Locked. The user writes the plain field (parent: SharedMut[Node]?) and nothing else. With this part the parent-link probe of #1649 compiles, prints root and loses no bytes.

To build

  1. Lowering: the lowering writes F1 as a plain non-owning pointer field and F2 as Weak. Reading an F2 field upgrades it and yields null when the target is gone.
  2. Test tests/compiler/tests/a_parent_link_in_a_tree_is_a_back_field.nika with .stdout (root): the probe of #1649.
  3. Existing tests that #1647 item 3 marked as “correct shape for step 4” now pass with their old expected output.

Done when

The probe of #1649 compiles, prints root and loses 0 bytes under valgrind, and the tests #1647 marked as “correct shape for step 4” pass with their old expected output; the commit that builds item 3 carries the Fixes line for this issue.

Files

The lowering of fields (where the lowered field types are chosen), its lowered .rs; the new test. No new error code. No new Rust beyond the lowered output.

Split from #1649 by Claude Code

Back to Open Issues