fn first(site: (int, String, int)) -> int sync { return site.0 } then `let…Open and answer this issue on GitHub.
ready, bugs · opened 2026-11-20 · updated 2026-11-22 · 2 comments
Filed by the driver from the Found: of the run of issue-2120 (#2120) (owner, 2026-11-06).
fn first(site: (int, String, int)) -> int sync { return site.0 } then let mut t: Vec[(int, String, int)] = [(5, "a", 1)]; t.sort_by_key(first); let at = t.binary_search_by_key(5, first) lowers to |a0| first(*a0), rustc E0507 (cannot move out of a shared reference), should compile as the lambda fn(s) { s.0 } does; suspected emit_arg_lent_params case 2 (#1504) in emit_core_args.nika, which emits *a0 assuming a Copy parameter type (check: a Copy-typed fn(x: int) in the same place compiles)
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
Brief queued: issue-2444
agent: builder model: opus max_turns: 200 budget_usd: 30 effort: medium —
Your work order is issue #2444, inlined below with its comments. There is no
brief written around it: plan your own steps from its To build list, build
them in order, commit after each finished step, and end when its Done when
holds (or at the limits of builder.md, reporting what is left). The
facts in your prompt are Core of docs/builder-facts.md; more on a topic:
nikaia run scripts/syntax.nika -- KEYWORD, a probe: nikaia run scripts/probe.nika -- SNIPPET.
Measure the issue against docs/issues.md while you work: what it lacked,
what was wrong in it. That answer goes into the report’s Issue: field.
A finding, a changed plan or a finished item also goes into the issue as a
comment (gh api repos/Nikaia-Foundation/Nikaia/issues/2444/comments -F body=@file,
ending with the Claude Code footer), rule I13.
develop in the main checkout; other agents’ uncommitted files are not yours: never touch or stage them.target/fast/nikaia run scripts/commit.nika -- REPORT (it adds exactly the report’s Files:); the driver pushes.cargo build --profile fast -p nikaia, lower-std and its fixpoint when a tools/*.nika changed, cargo fmt, cargo clippy --all-targets -- -D warnings, nikaia run scripts/pre-push.nika, the tests the issue names and the ones your change touches.CHANGELOG.md, badges and NK codes are the supervisor’s. New tests in Nikaia only: a Rust test file an older issue names is built as a tests/compiler/tests/ program, no Deviation: and no Issue: point (I9, #1671).Body:. Found: is only for what lies outside the area, cannot be fixed this run or needs a decision; the driver files it as an issue.std or the toolchain lacks stops the work, unless an ADR or Part I-III refuses it (name it): Result: blocked, Found: the gap with a probe, Needs: supervisor decision.NIKAIA_CACHE_LIMIT=2G; at the end delete your own clone’s target/ and target/release/nikaia-scratch.suspected, or does not mark (docs/issues.md I7), is a hypothesis: run the check that settles it (nikaia run scripts/where.nika -- NAME, the probe with a trace, callgrind for a cost) before you build on it (owner, 2026-11-16). Shown false: say so in Issue: as wrong I7: <what the check showed> (the driver comments it on the issue) and follow the real cause.Result: partial with what you ruled out, the probe, and the suspected file and function./home/user/Nikaia/docs/briefs/bugs/issue-2444.md.report.md)Fields: Result, Files, Commit, Body (optional), Fixes, Pushed, Tests, Gate, Deviation, Found, Needs, Changelog, Issue, Owner (a question for the owner), Comment (#N <text>, what to say on another issue; the driver posts it, one line each), Friction, Disk freed, and last Attribution: with your commit trailer lines below it.
Result:, Gate: (green or red <check>), Deviation:, Found: and the other fields with nothing to say hold the bare word: done, none. Anything after it reads as content.Result: done only when the issue’s Done when holds; partial with the items left otherwise.Deviation: only for an item of the issue built otherwise than written, or not built. Found: only for a defect outside your area, or one this run cannot fix: one defect per Found: line, with its probe and the output it gives, only the shapes that fail today, and the suspected file and function or cause unknown (#1695); a by-design behaviour is none (#1677). A correct program your own change refuses (a fail-closed check’s false refusal) is no Deviation: but one Found: line per shape, with its probe (#1680). Everything else goes into Body:; how you verified goes into Tests:.Issue: by docs/issues.md, How a run judges its issue: complete, or broke I<n>: ..., rules-gap: ..., wrong I<n>: ..., joined with ;; a point your own commit built gets (built) after its kind (rules-gap (built): ...), and the driver does not file it. complete is the bare word: prose after it (complete; the earlier runs ...) is filed as an improvement issue (#1931); history or a note for your own issue goes into Body: or Comment: #N <text>.done <sha>, report <path> (or BLOCKED: ... / PUSH REJECTED ...).Generated by Claude Code
Run: issue-2444, Result: partial: the issue’s exact probe (string literals in a list literal) still fails, through a separate text-tier defect filed as the Found below; the copied-part shape with owned text is fixed
Tokens: input 108, cache read 3197671, cache write 69604, output 20311 Cost: 1.65 USD, time 5 min 14 s, turns 54
Result: partial: the issue’s exact probe (string literals in a list literal) still fails, through a separate text-tier defect filed as the Found below; the copied-part shape with owned text is fixed
Files: crates/nikaia-std/src/compiler/keeps.nika crates/nikaia-std/src/compiler/lowered/keeps.rs crates/nikaia-std/src/compiler/lowered.rs tests/compiler/tests/a_copied_part_of_a_tuple_parameter_keeps_nothing.nika tests/compiler/tests/a_copied_part_of_a_tuple_parameter_keeps_nothing.stdout
Commit: A tuple parameter’s parts are its fields in the keep pass: handing back a part that copies (return site.0) keeps nothing of the tuple
Body: keeps.nika keeps_uses_of gave only struct parameters a field table, so a_field_that_copies read a tuple parameter’s site.0 as unknown and kept site. So fn first(site: (int, String, int)) -> int { return site.0 } lowered by value: first(t); first(t) drew NK2105, and xs.sort_by_key(first) was rustc NK1343 (fn((_, Text, _)) where fn(&(_, Text, _)) is wanted). Now each part gets a field by position, so the parameter is lent (first(site: &(i64, String, i64))), as return site.n of a struct already was. Before: the new test drew NK2105 twice on $NIKAIA_OLD; after: it prints 5 5 a / b true.
Part: #2444
Pushed: local f290348a4b0b3b8fc831b3e01578d29e1620ad8e
Tests: new test a_copied_part_of_a_tuple_parameter_keeps_nothing green –both-settings, failed on $NIKAIA_OLD (NK2105 x2); tests/compiler –filter tuple 68 ok, –filter keep 132 ok; it keeps:: 33 ok; lower-std fixpoint (2nd run changed nothing besides my keeps.rs/lowered.rs); clippy nikaia-std –features compiler clean; pre-push green
Gate: green
Deviation: none
Found: fn first(site: (int, String, int)) -> int sync { return site.0 } + fn main() throws { let mut t: Vec[(int, String, int)] = [(5, "a", 1), (2, "b", 3)]; t.sort_by_key(first); let at = t.binary_search_by_key(5, first); println(f"{t.len()} {at ?? -1}") } on HEAD+this fix gives NK1343 “Expected reference &(_, nikaia_std::block::Text, _) found reference &&(_, &'static str, _)” (the lowering is let mut t: Vec<(i64, &'static str, i64)> = vec[...]; t.sort_by_key(|__nikaia_a0| first(&__nikaia_a0))), should print 2 1 as the same program with the strings made by a fn make with push_str does; suspected text_tiers.nika: the list literal’s text parts are tiered to &'static str although the list is handed to a named function value whose parameter holds an owned String (check: nikaia check --tethers on the probe, then trace where the tier pass reads named fn values)
Found: fn klen(x: String) -> int sync { return x.len() } + fn make(s: String) -> String { let mut g = String(); g.push_str(s); return g } + fn main() throws { let mut t: Vec[String] = []; t.push(make("abc")); t.push(make("b")); t.sort_by_key(klen); println(f"{t[0]}") } gives NK1343 “Expected function signature for<'a> fn(&'a nikaia_std::block::Text) -> _ found function signature fn(&str) -> _” (lowered t.sort_by_key(klen) bare), should print b as t.sort_by_key(fn(s) { s.len() }) does; suspected emit_core_args.nika emit_arg_lent_params: a text parameter lent as &str at a fn(ref T) slot with T = String counts as matching (both lend), so no closure is written around the name (check: the same with xs: Vec[Site] of a struct passes bare and compiles)
Needs: none
Changelog: A function that hands back a number out of its tuple parameter (return site.0) now only borrows the tuple: the caller can use the tuple again, and the function can be handed to sort_by_key and binary_search_by_key.
Issue: wrong I7: the suspected emit_arg_lent_params case 2 (*a0) was not the cause; HEAD wrote no closure at all, because keeps.nika keeps_uses_of built no field table for a tuple parameter, so return site.0 kept the tuple and first was lowered by value; the issue’s probe with literal strings also hits a separate text-tier defect
Owner: none
Comment: none
Friction: none
Disk freed: none (target/nikaia-project-tests 2.9G, / 9.0G free, no new entry over 100 MB)
Reviewed: 615bc000c524d28c912ea2795f4a5d68fb6c93842280bfe57e549ed83ac51c44
Attribution:
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01UVxJDutPTwP5Xj5HkGuidk
keeps.nika change re-lowers std. The second biggest cost was following the issue’s suspected cause (emit_arg_lent_params). Varying the shape (struct parameter, return 0, return site.1.len()) moved it to keeps.nika in a few probes.Expr::Field with the name "0". Where KeepsBody.fields is built (keeps_uses_of). That block::Text is what String lowers to under the block setting.$NIKAIA_OLD, one cycle, the new test with --both-settings, tests/compiler --filter tuple and --filter keep, it keeps::, clippy on nikaia-std, pre-push.Deref for Text led nowhere.|a0| first(*a0)) is not what nikaia lower shows today, distrust the suspected function and vary the shape first”.wrong I7: it suspected emit_arg_lent_params case 2, but no closure was written at all. The cause was in keeps.nika keeps_uses_of: a tuple parameter had no field table, so return site.0 kept the tuple.wrong I5: the quoted output (first(*a0), E0507) did not match today’s lowering. The probe mixed two defects: the keep pass, and how the literal strings get their text type.rules-gap: no rule asks a probe to keep to one cause. Here the literal strings brought in a second, separate defect.| Fact: Probes | A probe of a named function value over a list of text should build its strings with a fn make and push_str: string literals in a list literal are lowered as &'static str and add a second, separate rustc mismatch. |
| Fact: Lowering and lower-std | keeps.nika reads a parameter’s parts through context.fields (built in keeps_uses_of), and a parameter with no entry there is kept whatever is returned; tuple parts are fields named "0", "1", … since f290348a. |
Generated by Claude Code