Open and answer this issue on GitHub.
compiler, ready · opened 2026-11-15 · updated 2026-11-15 · 0 comments
Part of #1626. Step 3 of 5 of ADR-shared-handle-cycles-1. It rests on #1647 (the rule within one function).
After #1647, a store whose value comes from a call or a parameter of a self-reaching type is unknown, and an unknown store is refused. This issue gives every function a summary, so those stores are judged instead: correct programs that pass handles through helpers compile, and a cycle closed in a helper is still refused.
struct Node { name: String, next: SharedMut[Node]? }
fn link(from: SharedMut[Node], to: SharedMut[Node]) {
from.update(fn(mut v) { v.next = to })
}
fn fresh(name: String) -> SharedMut[Node] {
SharedMut(Node { name: name, next: null })
}
fn main() throws {
let a = fresh("a")
let b = SharedMut(Node { name: "b", next: a })
link(a, b)
print("built")
}
link is refused as unknown: parameter.NK1352 at the call link(a, b). The note names the store in link and says “b reaches a”. With link(b, fresh("c")) instead, it compiles: fresh reaches nothing.The probe is refused at the call, the variant compiles, the tests below pass, and measurement 5 of #1626 §9 is posted again: how many unknown refusals the summaries remove from #1647’s count.
check_cycles.nika: for each function, compute its reach-and-store summary from the per-function walk of #1647, and solve them bottom-up over the call graph. Reuse the call graph and reach_index_of from check_doors.nika; no second call graph. Strongly connected parts of the call graph are iterated to a fixed point.check_program_instantiations_beside (check_program.nika) already visits them.check --cycles prints each function’s summary in one line under the type list of #1646.tests/compiler/tests/:
a_cycle_closed_in_a_helper_is_refused_at_the_call (the probe, .stderr);a_handle_from_a_constructor_function_reaches_nothing (the variant, .stdout);a_cycle_closed_through_mutual_recursion_is_refused (.stderr);a_call_through_a_trait_object_is_judged_conservatively (.stderr);a_generic_helper_that_links_handles_is_judged_at_its_instantiation (.stderr).crates/nikaia-std/src/tools/, packages/ and examples/. If #1647 held back the refusal at stop point 1, it is switched on here once unknown refusals of correct code are gone, and this issue says so.Summaries over the call graph are also built for door reach (check_doors.nika) and lock order. Use the same graph and the same order of solving; do not add a third.
crates/nikaia-std/src/tools/check_cycles.nika and its lowered .rs; the new tests.NK1352.nikaia check crates/nikaia-std/src/tools/check_program.nika may grow by at most 5 % over #1647’s figure.