Repository navigation
fix(nameref): sync typed array cell with mirror on declare/local and circular-fallback writes (Refs #2655) - #3484
Conversation
…circular-fallback writes (Refs #2655) Assignment through a nameref to an array element updated only one of rubash's two variable representations, and the debug-only command-boundary verifier panicked on the next check ("typed cell disagrees with its mirror", variable_state.rs:1095 indexed / :1109 assoc). Two one-sided write paths: * declare/local/typeset through a nameref wrote the resolved target's mirror only: the post-declare sync (sync_typed_assignments) synced the operand name (b), never the resolved target (a for b -> a[0]). It now also syncs the chain target's base (nameref18/21/22/23.sub). * a write through a circular nameref (assign_circular_fallback) wrote the global namesake's array/assoc mirror snapshot only, never the typed snapshot beside it. It now rebuilds the saved typed cell from the same render (nameref15.sub). Regression pins: tests/issue2655_nameref_array_element_write_regressions.rs (8 tests). The run-nameref suite no longer panics; nameref15/18/21/22/23 match GNU byte-for-byte on stdout (5.2.21) and nameref15/21/22/23 match the pinned 5.3 .right with zero diff.
|
Thank you for this PR — and for taking on #2655, the harvest V1 nameref PANIC (typed cell vs mirror desync, What I have captured from the PR description:
What happens next: per the owner's rule, external PRs go through captain review first — this PR is now queued for captain review, and CI is being watched. One thing already visible: the Rust tests check currently shows fail while the run is still in progress (other legs passing or pending), but its logs are not available yet, so I am not drawing any conclusion about the cause — the captain review will read the failed logs once they are published, and will re-run the new nail stem itself rather than trusting CI green alone. No merge from intake, and no change requests from me at this stage — the review above is a first-pass intake note only. |
Fixes #2655 — PANIC (crash class) when assigning through a nameref to an array element.
Root cause
A write through a nameref updated only one of rubash's two variable representations (typed cell vs mirror string), and the debug-only command-boundary verifier then panicked (
typed cell disagrees with its mirror,variable_state.rs:1095indexed /:1109assoc). Two one-sided write paths, one mechanism family:declare/local/typesetthrough a nameref wrote the resolved target's mirror only: the post-declare sync (sync_typed_assignments) synced the operand name (b), never the resolved target (aforb -> a[0]). It now also syncs the chain target's base (src/builtins/declare.rs). This covers nameref18/21/22/23.sub (e.g.declare b+=1moved the mirror to 6 while the cell still held 5).assign_circular_fallback) wrote the global namesake's array/assoc mirror snapshot only, never the typed snapshot beside it. It now rebuilds the saved typed cell from the same render (src/executor/variable_state.rs). This covers nameref15.sub (a=Xthrougha -> amoved the mirror to "X" while the cell kept "0").The plain-assignment funnel already synced both sides, so the issue's minimal snippet (
f 'a[0]'failing sh_invalidid) never panicked on its own.Tests
tests/issue2655_nameref_array_element_write_regressions.rs— 8 tests (circular indexed/assoc/append, declare bind/append through nameref,local -Acompound, invalid-id guard). All pass.run-namerefupstream suite (scripts/run-bash-upstream-tests.sh run-nameref): no longer panics — 0 panic mentions (baseline: 10). nameref15/21/22/23 match the pinned 5.3.rightwith zero diff; nameref18's remaining diff is the pre-existingrechoharness gap, also present on master.typed_cell_coherence_fuzz,issue1719, sync corpus (issue2036/2043),cargo test --lib(1250 tests),cargo fmt --checkclean.issue1046_groups_variable_regressions(GROUPS order on this host) andissue2043_a2_comsub_basename_extra_operand(system basename prints Unicode quotes).