same(inc)(1)? (parser refuses it today)Open and answer this issue on GitHub.
decision · opened 2026-10-31 · updated 2026-10-31 · 0 comments
agent: builder model: opus max_turns: 80 budget_usd: 15 — Found by the architect at 3ebedbca while probing #1034 step 2. Kind 2 of CLAUDE.md, A missing form stops the work: no ADR or Part I section refuses it, none allows it.
A function may return a function value (Part I 5.4, A function type stands wherever a type does; its example adder(3) binds the result with let add = adder(3) before calling add(1)). Calling the result directly is refused by the parser:
fn inc(x: i64) -> i64 {
return x + 1
}
fn same(f: fn(i64) -> i64) -> fn(i64) -> i64 {
return f
}
fn main() {
let v = same(inc)(1)
println(f"{v}")
}
nikaia run: Expected } here, but found ( at (1). The same inside an f-string hole. b.run(2) (a field of fn type, called like a method) and let g = same(inc) / g(1) run.
let first. For: no grammar change, the Part I example already reads this way; one name per step. Against: an irregularity: every other expression of a type can be used where its type is wanted, a function value only after a let; a converter (rs2nika) meeting f(a)(b) must invent a name.fn type, ( on the same line: same(inc)(1), xs[0](2), (make())(3). For: what Rust, Go, Kotlin, Swift, Python and JavaScript do; composes with returned lambdas (#1034). Against: a statement starting with ( after a line ending in a call could read as a call; the same-line rule (Go’s and Kotlin’s answer) settles it, and Nikaia already has no ; to lean on.f(a)(b), not xs[0](2)). For: the smallest change. Against: two rules where one does; an index of a list of functions is as natural.B: one rule (any postfix expression of fn type is callable, the ( on the same line), Part I 5.4 gains one sentence and its example may write adder(3)(1).
( is on the same line. Checker: the callee’s type is Ty::Fn, else a refusal naming it (existing code if one fits; a new one from the supervisor). Test tests/compiler/tests/a_call_of_a_returned_function.nika (same(inc)(1) -> 2, fs[0](2) with let fs: Vec[fn(i64) -> i64] = [inc] -> 3, and a ( on the next line staying a new statement).Read docs/builder-facts.md. No new NK code without the supervisor’s block.
Generated by Claude Code