Issue #953: tools/*.nika: rewrite the P5 workarounds over forms that exist (zip, map iter, mutable map view)

Open and answer this issue on GitHub.

ready · opened 2026-10-29 · updated 2026-10-29 · 1 comment

Debt over forms that exist (CLAUDE.md A missing form stops the work; P5 debt review by the architect, 2026-10-29). The P5 moves and older ones wrote around forms they believed missing. Each probe below runs on today’s develop (target/fast/nikaia run), so these are not gaps: the code is rewritten to the form.

Believed missing The form (record) Probe Sites
zip a.iter().zip(b.iter()), a.drain().zip(b.drain()) (Seq::zip, ADR-293 D20) for (x, y) in a.iter().zip(b.iter()) { println(f"{x}{y}") } prints x1, y2 project_lower.nika:202-206 (P5b, index loop over the shorter length); index loops of the same shape: sharing.nika:734, ty.nika:1828, emit_order.nika:110, project_tests.nika:408
a map’s .iter() m.iter().filter_map(fn((k, v)) { ... }) (BTreeMap::iter in std.contracts) m.iter().filter_map(fn((k, v)) { let b = other.get(k) ?? return null; ... }).collect() runs project_check.nika:408, :436 (P5d, outer for (name, contract) loop; optional: the loop is not wrong, only the reason was)
get_mut (in-place change of a map’s value) let mut c = m[k] ?? continue is a mutable view of the entry (ADR-282 D7, #816) let mut c = m["a"] ?? return; c.ensures.push("e") changes m project_lower.nika:200, :216 (P5b, get-clone-insert). The .get(k) spelling of it is a defect, #952
opt.as_mut() narrow, then write: if o != null { o.n = 2 } (ADR-382; lowered as as_mut().unwrap()) prints 2 the docs/selfhosting-gaps.md row ?.clone(), change, write the option back; no site found by grep

Design, not debt: hex.scalars.take(16).collect() at project_settings.nika:466 (P5e) where Rust cut hex[..16]: Part I 2.6 refuses a cut at a made-up number (NK1214) and names the view instead (hex.bytes[0..<16].text() or a take on scalars/graphemes). It stays.

To build

  1. project_lower.nika project_lower_published: let mut contract = ledger.functions[key] ?? continue, no insert back; the kept pairs with zip. The copy of ensures/from into kept stays until the mem::take decision is built (#949); do not write another way around it.
  2. The four index loops above to zip where the body reads both lists at one index only.
  3. lower-std, the touched tests, commit.

Generated by Claude Code

Comments

keywan-ghadami, 2026-10-29

Built in dec953b: step 1 (project_lower_published takes the mutable view via get, #952, and zip; the copy into kept stays until #949) and step 2 at sharing.nika class_before and emit_order.nika emit_order_overlap. Left, nothing written around them:


Generated by Claude Code

Back to Open Issues