Result: done
Files: crates/nikaia-std/src/tools/check_core_method.nika crates/nikaia-std/src/tools/check_core_stmt.nika crates/nikaia-std/src/tools/check_facts.nika crates/nikaia-std/src/tools/check_flow.nika crates/nikaia-std/src/tools/emit_core_calls.nika crates/nikaia-std/src/tools/lowered/check_core_method.rs crates/nikaia-std/src/tools/lowered/check_core_stmt.rs crates/nikaia-std/src/tools/lowered/check_facts.rs crates/nikaia-std/src/tools/lowered/check_flow.rs crates/nikaia-std/src/tools/lowered/emit_core_calls.rs tests/compiler/tests/a_let_mut_of_a_mut_maps_get_is_a_mutable_view.nika tests/compiler/tests/a_let_mut_of_a_mut_maps_get_is_a_mutable_view.stdout docs/briefs/b952.md.report.md
Commit: let mut x = m.get(k) ?? over a mut map or list is a mutable view (get_mut)
Body: ADR-293 D1 (the bracket says what get says) and ADR-282 D7: the checker records a get resolved to Vec::get, BTreeMap::get or HashMap::get (flow.std_gets); a let mut past a jump of such a get, of a value that is not copied out (a number, bool, char or a package copy type stays a copy), over a mut place is a mutable view: facts.mut_view_reads drops the binding's mut, facts.mut_view_gets (by receiver id) makes the emitter write get_mut. An immutable receiver is NK1139, as for m[k]. A user type's own get is untouched.
Fixes: #952
Pushed: none
Tests: nikaia test --both-settings tests/compiler 261 of 262 ok, the new a_let_mut_of_a_mut_maps_get_is_a_mutable_view ok; agent_script failed (ESCALATE: disk 2.9 GB free, under agent.nika's 3 GB floor; unrelated); gate set 23 ok; clippy clean; pre-push-check ok; issue probe prints 1; NK1139 probe on an immutable map; user get not renamed
Gate: green
Deviation: the unfixed run is the old binary's lowering of the issue probe (let mut c = match m.get("a") ..., rustc E0596), not a stash of the fix (no stash in the shared checkout)
Found: none
Needs: none
Changelog: `let mut x = m.get(k) ?? ` over a `mut` map or list is a mutable view of the entry, as `m[k]` is (`get_mut`), instead of Rust code rustc refused (#952).
Owner: none
Disk freed: none
Rs2nika: none (compiler fix, no move)
This site is open source.
Improve this page.