Open and answer this issue on GitHub.
decision, bugs · opened 2026-11-20 · updated 2026-11-20 · 1 comment
Filed by the driver from the Found: of the run of issue-1121 (#1121) (owner, 2026-11-06).
a function type’s own code parameter has no run-or-kept rule, and a lambda of that type may keep it today. Probe struct Box { f: fn() -> i64 sync } / fn twice(scoped: fn(i64, fn() -> i64 sync) -> Box sync) -> i64 throws { let b = scoped(1, fn() { return 2 }) / return b.f() } / fn main() throws { println(f"{twice(fn(at, run) { return Box { f: run } })}") } prints 2 and lowers the lambda to |at, run| { Box { f: run.clone() } }. So “run” in fn(i64, fn() -> i64 sync) cannot be read from the type. Run versus kept is inferred from a body (ADR-277 D8, D11) or from a trait’s default body and its own package’s impls (ADR-277 D17), but a function type has no body and no ADR decides it. Lowering the inner type to &dyn Fn() -> i64 breaks this program (run is borrowed for the call alone). The choices are: a word in the function type (for example fn(i64, keep fn() -> i64), lent by default, a keeping lambda refused) or a D17-like column made from every function handed to that type. No decision yet.
supervisor decision: how a function type’s own code parameter is run or kept (ADR-277 D8 and D17 cover a body and a trait method, not a function type), before #1121 can lower it to &dyn Fn
The Found does not say how sure its cause is (docs/issues.md I7): a cause it names is a hypothesis, unknown until checked. The second item checks it (nikaia run scripts/where.nika, a probe, callgrind) before anything is built on it; a cause shown false is answered wrong I7: ... in the report.
develop first: the run that wrote it may have used a binary older than the tip, so it may be fixed already (#1822: #1788 was filed from a probe a fix under #1754 had already made pass). A probe that passes there names the commit that fixed it (git log -400 --grep by topic, since a fix often lands under another issue’s number), and the run builds only a tests/compiler/tests/ test that pins it (docs/issues.md I13).std defect with a probe (nikaia run scripts/probe.nika -- SNIPPET; a lowered file that differs, with an uncached lower-std of a git archive HEAD copy, NIKAIA_LOWER_CACHE_SALT fresh and --sysroot COPY/crates, its lowered/ diffed against the copy’s, never the shared working tree’s, #1793), a defect in docs/, guide/, website/ or scripts/ (a stale example, a wrong rule) with the command or check that shows it; a behaviour the code does on purpose (name the function or ADR) closes it as by design. The Found line may lack them (#1710): the commit message, or the report’s Body: when closed, gives the probe or check with its expected output, the ADR or Part I-III section that says so, and its actual output (docs/issues.md I5, I6), and the cause, file and function, traced or suspected (I7).std defect in the compiler, a stale page example or rule in its page or docs/ file, a script defect in the script. Add a test in tests/compiler/tests/ unless a check that already runs turns red on it (name it: pre-push’s page-examples for guide/ and website/, check-adr-refs.nika for a docs citation).The probe or check gives the expected output the first item names from its ADR or Part I-III section, and a tests/compiler/tests/ test (or the named check) that failed on the unfixed tree is green; or the probe already passes on develop and a test pins it, naming the commit that fixed it; or the issue is closed as by design, naming the function or ADR.
Generated by Claude Code
Supervisor, 2026-11-20, after talking with the owner: the question is wider than “keyword or inference”. “Kept” must not mean Kept(Arc::new(..)) by default. Nikaia does not copy behind the programmer’s back, and the region analysis already knows when memory is freed, as the fix for #2348 showed. So before the run-or-kept rule is written, each case gets its cheapest shape, with a probe and a callgrind figure:
fn() { return 2 }). Its shape needs no heap at all: a function pointer or a &'static dyn Fn, whether it is run or kept.&dyn Fn or &impl Fn, with no allocation.b lives and dies inside twice. It can be lent with a lifetime, the way a returned box was built in the caller’s block in the fix for #2348.dyn and no heap.Box, not an Arc. An Arc is used only where ownership is really shared (ADR-312 D1).pub boundary with unknown foreign lambdas. The narrowest contract that still covers cases 1–5, following D17 (NK1264, NK1265).No new keyword (ADR-277 D8: nothing is written). The rule is inferred, and the ledger shows which shape each position got and why. The next step is a study that measures each case on the probe and in the compiler’s own call sites; it then gives the ADR text and the build items for #1121.
Generated by Claude Code