for c in text over a String passes check and fails in rustc (no method iter for &str)Open and answer this issue on GitHub.
ready · opened 2026-10-31 · updated 2026-10-31 · 0 comments
Found by the prover lane’s architect while probing p7 (2026-10-31, binary of 28acd94).
Part I (10-*.md :279, :810) walks text through .scalars (for c in name.scalars). A for directly over a String passes nikaia check and fails in rustc:
fn chars(text: String) -> i64 sync {
let mut n = 0
for c in text {
n += 1
}
return n
}
fn main() {
print(f"{chars("ab")}")
}
nikaia check prints Checked; nikaia run stops with error: No method named iter found for reference &str. A program the checker accepts must build (or the checker refuses it with an NK code and help naming .scalars).
check_core_stmt_for (crates/nikaia-std/src/tools/check_core_stmt.nika :1558) refuses a for over text with an existing NK code if one fits (a walk over a type that is not a sequence), else one from the bug lane’s block, help: walk \text.scalars` (or `.bytes()`). Or, if Part I already means for c in text to walk scalars, lower it so; Part I decides, cite the section. Test tests/compiler/tests/for_over_text.nika + .stderr`.Generated by Claude Code