once, lowered as impl FnOnce)Open and answer this issue on GitHub.
ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments
Part of #973 After #973
Step (b) of ADR-lambdas-1 (D3): a code parameter of a user function is once when its body calls it at most once on every path and hands it on only to a once parameter. A call in a loop, two calls or keeping it makes it many. This is inferred, written to the ledger beside kept and lent, has no syntax, and is lowered as impl FnOnce, so a user wrapper of entry or a lock works like std’s. The inference and the lowering go together: the accepted program only compiles under rustc once the parameter is impl FnOnce.
once.impl FnOnce (crates/nikaia-std/src/compiler/emit_core_types.nika, where code parameters are written as impl Fn(..)). Kept stays Kept<dyn Fn>.tests/compiler/tests/ (Nikaia, with .stdout): a user wrapper of entry accepting the move of a captured value into its lambda, run end to end.A user function that calls its code parameter once and hands it only to or_insert_with accepts a caller’s lambda moving a captured value, the program runs, and its ledger shows the parameter as once, shown by a test in tests/compiler/tests/; the commit that builds item 3 carries the Fixes line for this issue.
Split from #973 by Claude Code