Skip to content

fix(assoc): #860 unset empty-span/mask pseudo-diagnostic + #861 kvlist self-read miss - #883

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/860-861
Oct 19, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/860-861

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #860
Closes #861

What

Four residual faces of the #847 CR family, all byte-verified against the GNU bash 5.3.0 WSL oracle (probes 2026-10-19):

  1. mask-before-expand (subscript_expansion.rs): the escape mask folded $x\ty into the name $xty before the $name scan; GNU scans left-to-right and stops the name at the backslash. unset 'A4[$x\ty]' produced a bogus bad array subscript + rc1 instead of GNU's silent rc0.
  2. escape product as data (arithmetic/lvalue.rs, parser.rs, value.rs, mod.rs): S6[$\tx] keys on the literal text $tx (24 74 78), not on the expansion of tx.
  3. empty-span writes (unset_arrays.rs, array_assignment_exec.rs): ((U8[$'']=1)) / U7[$'']=1 / let "C9['']=1" now take GNU's ONE name[''] diagnostic with nothing stored (the ""/$u/[] token spellings keep the `name[]': not a valid identifier law).
  4. kvlist self-read miss (关联数组 kvlist 自读取 miss(写 parity 读丢,静默类)——#847 CR 残余 b #861): the strict name=( [key]=value ) path stored the span's E010/E011 quote markers inside the key, so the same-spelling read missed silently and a clean-spelling overwrite made a second cell; dequote_compound_subscript now restores the markers to literal bytes (write parity, one clean cell).

Verification (full-suite, serialized batch)

  • Branch merged with current origin/master (41bfdd3, 15 commits ahead — mark_quoted_ifs_from_raw simulator is carrier-blind: carrier-laden raw words silently lose per-char IFS marking #868/mark_literal_ifs_chars 对未闭合 $(…/反引号 词的 raw-skip 哨兵越界:copy 循环 index == len 时 panic 整个 shell(niu 1.4.1 journey P7 崩溃面) #875 etc.) before verification; catalog conflict resolved by keeping both rows.
  • cargo test --no-fail-fast -- --test-threads=1, full suite, compared bidirectionally against a pristine detached origin/master worktree on the same machine:
    • 34 failures in the stable core, byte-identical sets across branch and master full runs — all pre-existing divergences (catalog diverges rows and known Windows-environmental faces).
    • Per-run deltas were proven flakes/unrelated: windows_listing_cache... (master-side run flake, 6/6 pass standalone), fixture_text_tree... (nondeterministic profiler self-time tie order — also fails standalone on pristine master ~1/6), fractional_timeout_expires_with_142 (fractional-timer vs read race under serial load; passes standalone).
    • Zero new failures attributable to this branch.
  • Four expectations in the new tests/issue860_*/tests/issue861_* files were initially authored against pasted (unverified) faces and failed everywhere including GNU; corrected to the oracle truth — rubash matches GNU byte-for-byte on all four (e.g. GNU keeps declare -p U7 silent after the refused U7[$'']=1 write, and the surviving x\ty key lists raw as 78 09 79\n).
  • New regression tests: tests/issue860_assoc_empty_key_regressions.rs (17) + tests/issue861_kvlist_selfread_regressions.rs (9) — all green; catalog rows issue-860/issue-861 (must-match) with scripts/regression-catalog/cases/*.sh.
  • cargo fmt --check clean. RUSTFLAGS=-D warnings cargo check --all-targets fails on 16 pre-existing test-crate warnings whose set is identical on pristine master (src/ crates clean); no new warnings.

CI green → ready for merge by the maintainer.

…t self-read miss

WIP — full-suite verification pending a serialized batch (cargo test
--test-threads=1, fmt, -D warnings, bidirectional). Probes are
byte-verified against the WSL GNU 5.3.0 oracle and the regression
catalog is green (38/38 declared expectations); the cargo test run has
NOT happened yet.

#860 (mask-before-expand): mask_subscript_escapes collapsed an unquoted
backslash escape BEFORE the parameter walker, folding $x\ty into the
name $xty -> empty key -> bogus '[...]: bad array subscript' + rc1 on
unset 'A4[$x\ty]' (GNU: silent rc0, key ty). GNU scans left to right:
the $name extraction stops at the backslash (subst.c:10934
param_expand's legal_variable_char loop) and the escaped char rides
after it (subst.c:11614 case '\\'). Fix: an escaped name-character is
emitted behind the PARAM_NAME_END_MARKER boundary (the #742 law); the
embedded walker's tail strips the marker.

#860 (empty-span writes): the arith pre-encode pass classified an empty
resolution by the arith token text (sq survives, dq strips, spans
re-quote) and emits the class to the parser; new ArithLValue::AssocEmptyKey
gives GNU's two laws: bind = name['']: bad array subscript once, no
store (arrayfunc.c:402-407 err_badarraysub); read = the bare NAME once
(INDEX_ERROR, arrayfunc.c:1462-1470). Empty-token spellings
(""/$u/[]) keep the name[] law (bind: not a valid identifier; read:
a[] x2). set_assoc_element rejects empty keys.

#861 (kvlist self-read): dequote_compound_subscript restores the
lexer's E010/E011 data-quote markers in its cooked-text tail, so the
strict [key]=value path stores the same clean bytes the assignment
entry stores (master stored pre$<E010>x<E010>post: write parity, read
miss, clean overwrite made count=2). Plus the plain-path diagnostic
cooks $'' -> '' (parse-law word) and the kvlist diag prints the parsed
element word; a declared-unset assoc no longer materializes on a
retain-only unset.

Regressions: tests/issue860_assoc_empty_key_regressions.rs (17),
tests/issue861_kvlist_selfread_regressions.rs (9), catalog cases
issue-860/issue-861 + manifest rows (must-match, runner 38/38).
Residuals documented on the PR: kvlist diag word for span/param
spellings (compound-body cooking), $'' scalar-arith error token,
[''x]-class partial-sq keys, declare-line abort law — all
master-equal, out of ticket scope.
# Conflicts:
#	scripts/regression-catalog/manifest.tsv
…gressions to the WSL oracle truth

The four cases were authored against pasted hex/declare faces that no
implementation (including GNU bash 5.3.0, byte-verified on the WSL
oracle) produces; rubash already matches GNU byte-for-byte on all four:

- escaped_char_stays_out_of_dollar_name / kvlist_bare_span_key_decodes:
  the `tr -d ' \\n'` pipe eats od's trailing newline — GNU's listing has
  none, drop the stray \\n.
- plain_empty_span_write_rejected: after the refused U7['']=1 write GNU
  keeps `declare -p U7` silent (empty stdout, one stderr line) — the
  declared-empty listing face was assumed, not verified.
- unset_deferred_span_quote_removal_unchanged: the raw od -An -tx1
  listing of the surviving key is ' 78 09 79\n'; the pasted 24275c7479
  matches no observable face of the probe.
@caomengxuan666

Copy link
Copy Markdown
Member Author

Independent CR verdict: APPROVE-WITH-NITS

Reviewed at 66efaa47 vs master@41bfdd36 in a detached review worktree (no files touched outside it; worktree removed after review). All checks re-executed from scratch, not trusted from the PR description.

Oracle (WSL GNU bash 5.3.0(1), /usr/local/bin/bash, LC_ALL=C.UTF-8, bash -c replication, byte-level):

  • All 4 corrected assertions match GNU byte-for-byte, and all 4 OLD values diverge from GNU (reverse-checked, so the corrections move toward the oracle, not toward the implementation):
    • escaped_char_stays_out_of_dollar_name: GNU stdout is 247478 with no trailing LF (tr -d ' \n' eats od's newline). Old 247478\n wrong.
    • plain_empty_span_write_rejected: GNU stdout empty, one stderr line, rc 1. Old declare -A U7\n wrong.
    • unset_deferred_span_quote_removal_unchanged: GNU od -An -tx1 of the surviving key is 78 09 79\n. Old 24275c7479 matches no observable face.
    • kvlist_bare_span_key_decodes: GNU stdout 70726578706f7374, no trailing LF. Old value wrong.
  • Reverse-masking scan: 7 of the 22 unmodified tests re-verified against the oracle (unset_mask_empty_span_keeps_silent, unset_mask_resolves_name_ended_by_backslash, reader_mask_boundary_hits_stored_cell, arith_empty_token_write_invalid_identifier, arith_plus_eq_empty_span_two_diags_no_store, kvlist_same_spelling_read_hits, kvlist_clean_overwrite_is_one_cell) — every sampled face is GNU/rubash-agreed. No sign of assertions being bent to a broken implementation.

Scope / merge hygiene:

  • 66efaa47 touches only the two test files (no src changes this round, as claimed).
  • Merge ef6bfe9a vs the branch parent differs only in files master changed — zero smuggled files. manifest.tsv conflict resolved with BOTH sides preserved (branch issue-860/issue-861 + master issue-868).
  • The only file where the merge deviates from master's side is src/executor/command_prepare.rs (use-item order swap). Verified necessary: pristine master fails cargo fmt --check at exactly that spot; the branch passes.

Full verification (all re-run here):

Nits (non-blocking):

  1. The commit message of 66efaa47 says GNU's declare -p U7 "goes silent afterwards". The verified mechanism is coarser: in the one-line ;-list face, bash 5.2 and 5.3 alike abort the rest of the list after the refused write, so declare -p never executes. The encoded face (empty stdout, one stderr line, rc 1) is exactly right; only the explanation is imprecise.
  2. The catalog now reports PROMOTE lim-f5-fd-cap (#773): the limits: fd table caps at 1014 with "cannot duplicate fd: Invalid argument"; read counts NUL bytes where cmdsub drops them silently; closed fd 0 then redirect errors #773 fix landed on master and the case now matches GNU, but its manifest row still says diverges — stale row inherited from master via the merge. Fine to flip in a follow-up.

@caomengxuan666
caomengxuan666 merged commit 2b98675 into master Oct 19, 2026
8 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 20, 2026
…ss gate (#944)

* test(regression): #746 catalogue second batch + manifest exhaustiveness gate

- manifest rows for the four case files that shipped unscored:
  issue-860/861 (PR #883), issue-868, issue-876 - all must-match
- ten new cases: issue-699/701/830/832 must-match (closed/fixed);
  issue-700 and issue-846 diverges (residuals tracked as rubash#938 and
  rubash#940); issue-840/856/871/879 diverges (open)
- runner: stage each arm in its own work dir (out/<case>/{arm,gnu}/) so
  one arm's fixture mutations cannot contaminate the other; remove dead
  SCRIPT constant
- runner: UNSCORED (case file with no manifest row) and DANGLING
  (manifest row with no case file, full runs) are reported and fail the
  run with exit 2 - an unscored case is a hole in the ratchet
- README: document the batch, the UNSCORED/DANGLING rules, and scope

Verification note: arm-side staging + bounded runs were executed under
target/debug/rubash.exe only; the WSL GNU 5.3.0 oracle leg was not run
this session. Declared states follow the case authors' byte-verified
probes; a full catalogue run is the confirming measurement.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>

* test(regression): PR#944 review rework — cwd-tail probe for issue-830, flip issue-871 to must-match (#746)

issue-830 (BLOCKER): the case printed the full physical cwd via pwd -P,
but the per-arm staging (out/<case>/{arm,gnu}/) puts the two legs on
necessarily different paths, so the normaliser could only shrink them to
/mnt@P@ vs @p@ — the row declared must-match and could never match:
every full run exited 1 on a permanent false ALARM.  Probe the tail
segment instead (basename "$(pwd -P)"); the ticket substance
(PWD-tail=sub, phys=sub, rc) was already identical on both sides and
stays pinned.

issue-871: the declared-diverges row is stale — the infin/nann/infx/nanx
face (value + invalid-number diagnostic + rc 1) is byte-identical to the
GNU oracle.  Flip to must-match; case comment and README row updated.

Verified differentially (arm built at 0c50b41, WSL GNU bash leg, no
skips): full 51-case run exits 0 with no ALARM and no UNSCORED/DANGLING;
negative control (issue-700 temporarily declared must-match) alarms and
exits 1, so the ratchet still bites.

---------

Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666
caomengxuan666 deleted the fix/860-861 branch October 21, 2026 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant