Repository navigation
fix(executor): route dynamic assoc whole assignments to owner tables (Refs #3211) - #3220
Conversation
|
Captain review: FAIL for the current head (2026-11-14) — with captain ruling (b) split, below. The PR's own mechanism is correct; the head still cannot merge as-is. What passesThe dynamic-assoc gate is the right mechanism (same shape as the DIRSTACK gate), the GNU anchors are exact (variables.c:1715 / 1785 / 1895-1897 / 3140, subst.c:3441, arrayfunc.c:700 — all read first-hand), and of the pin's 11 cells the base runs 3 green / 8 red with the head flipping exactly the 7 gate cells to green: head 10/11. Neighbour stems, lib bilateral (1206/0/4 both sides, failure name sets empty on both), The one red cell is a real product divergence — in a different face
The pin's expectation is the GNU truth — the pin is not wrong. The divergence lives in the generic compound-assignment type inference for undeclared names, which this PR's gate deliberately stands down from. It is not a baseline red carried over unchanged: the failure shape differs between base and head. Captain ruling: (b) split
Two record items for the #3211 close-out (not blocking): declare/typeset/export operand forms are not routed by this PR and have no pin (GNU routes them through the same hooks) — the merge-round three-way probe will measure them and the captain will either extend this wave or file separately; and the element-form illegal-alias-name status observation in the lane report (§2/§6, GNU rc=0 vs rubash exit 1) stays on record for the same decision. |
…set binds stay plain (Refs #3573) ## 修了什么 `unset BASH_ALIASES` / `unset BASH_CMDS` 从不记录 UNSET_DYNAMIC_VARS:dynamic_parameter_is_set 只服务标量动态登记表,不含这两个 owner 表驱动的 assoc 变量。后果有四: - #3220 的动态门对 unset 名字永不让位; - declare -p 继续拿 owner 表渲染(`declare -A BASH_ALIASES=()`); - alias / hash 操作复活已解绑变量; - 元素绑定/解绑误操作 owner 表。 本次按 GNU variables.c:3788(unbind_variable;:1194-1195 解绑后“失去特殊含义”)在三处解绑记录点(unset builtin、view_unset_variable、jobs 内 unbind)补记,并在 publisher、元素绑定臂、元素解绑臂兑现该标记。通用复合赋值路径本身不动(新鲜名字本来就是对的,见钉锁)。 回归钉:tests/issue3573_unset_dynamic_assoc.rs(14 格;fail-first 在 d374e78 预修二进制上实测:11 格红、3 格锁绿;期望全部取自 GNU bash 5.3.20 oracle)。 GNU 锚点:variables.c:3788 unbind_variable、:1194-1195;subst.c:3441 do_compound_assignment;arrayfunc.c:507 assign_array_from_string、:700 assign_compound_array_list。 ## 删了什么 无(纯修复 + 新增钉文件)。 ## 碰撞 - 与 PR #3220 同文件 src/executor/dynamic_arrays.rs,不同 hunk(本 PR 只动 publish_dynamic_assoc_var;#3220 在同文件新增 apply_dynamic_assoc_assignment 等三函数,约 1870 行一带);合入顺序由队长定,后合者 update-branch + 合并形重验。 - 未碰 src/executor/temporary_assignments.rs(#3220 的门)、assignment_expansion.rs(#3501 在途)、src/lexer/continuation.rs(队长专属)。
|
Captain focused re-review of the rework delta: PASS. The original FAIL (comment 6873800335, ruling (b) SPLIT) faulted only the one red cell in a different face (#3573); the dynamic-assoc gate itself was judged correct. The rework removes exactly that cell and nothing else:
Merge round notes: head is already update-branched to |
…(Refs #3500) ## Summary A bad substitution inside a compound-assignment element was diagnosed with the `${...}` fragment instead of the element word. GNU quotes the whole element and reports the word being expanded, e.g. `a=([0]=${-x})` → `\[0\]=${-x}`. ## Root cause `subscripted_parameter_element` hands the RHS to `whole_word_parameter_single_value`, whose `has_word_operator` arm misjudges `${-x}` (empty `var_name` at position 0) and expands it standalone with no pending diagnostic word installed, so `expand_braced_parameter_word` falls back to the synthesized `${-x}` fragment. The plain-element path had the same gap (the walker default names the raw token, without `quote_assign`'s `\[sub\]` quoting). ## Fix - New `compound_element_diag_word` (module level, mirrors GNU `quote_assign`): indexed `[sub]=value` → `\[sub\]=value`; assoc elements → the bare value; a quoted value keeps the fragment's own word. - The element word is installed as the pending diagnostic word at the two element-expansion sites (`subscripted_parameter_element`, `compound_plain_element_value[_fields]`), install-if-absent. - An `assoc` parameter is threaded through `expand_compound_positional_at_assignment[_bare]` (4 call sites), computed by new `compound_assignment_is_assoc` (live `ASSOC_VARS` marking OR the declare-assoc hint). - New declare-assoc thread-local hint (`DECLARE_ASSOC_HINT` + RAII guard), installed by the `declare_assoc_operand_names()` scan in `command_prepare.rs`, covering the `declare -A` command-word expansion path, which runs before the declare builtin. - Bare (eval-argument) flatten installs no word: documented residual, not fixed here. GNU anchors: `arrayfunc.c:557/:581/:594-599/:606/:630/:938-977/:1108-1129`; `subst.c:10278`. ## Regression pin `tests/issue3500_compound_elem_diag_word.rs` — 19 cells (10 fix shapes + 6 guard shapes + 2 quiet guards + 1 first-bad-wins). Expectations verified against GNU bash 5.3.20. ## Verification (captain-verified legs) - Merged head `d11ffbcf` (update-branch of `00c0a07` onto tip `021705cf`, three update-branch rounds: `8eb07872` (#3510), `12aa434e` (#3455, disjoint files), `021705cf` (#3220, disjoint files); intersection `{src/executor/assignment_expansion.rs}` via #3599, hunks ≥164 lines apart, no overlap): pin **19/19**; same-file neighbor issue3501 pin **68/68**; adjacent assoc-face issue3573 pin **14/14**. - Fail-first (top-up form on base `11719895`): pin 11/19 — 8 red, each reporting `Some("${-x}")` where the element word is expected. - Neighbor `array_compound_quote_regressions` 17/17 on head. - Full lib bilateral (bin built first): base 1247 passed / 0 failed / 4 ignored; merged head 1249 passed / 0 failed / 4 ignored — failure name-set diff empty (the +2 are the tip's Mach-O unit tests from #3510). - `RUSTFLAGS="-D warnings" cargo check` RC=0, 0 warnings; `cargo fmt --check` RC=0; utf8-boundary hygiene clean. - Head CI run `43619058744` (on `10da84b4`, the second update-branched head): 3 failing jobs, sole FAILED name `issue2875` (known baseline). A fresh CI run starts on the final head `d11ffbcf` from the third update-branch; it differs from `10da84b4` only by the disjoint #3220 merge. - `continuation.rs` untouched. Refs #3500 ## 本 PR 删除了什么 Nothing — purely additive fix plus the new regression pin. No code, test, file, or behaviour removed.
Refs #3211 — UNVERIFIED-BY-CAPTAIN
根因(机制定性)
动态变量整表复合赋值缺属主落点钩子。GNU 把 BASH_ALIASES / BASH_CMDS
注册为带元素 assign hook 的动态变量(variables.c:1882-1897
initialize_dynamic_variables):valid_alias_name校验后add_alias;非法名报错跳过该元素、其余照落、语句 rc 不变phash_insert(key, value, 0, 0):被点名条目 hits 重置、未点名条目原样保留整表赋值无第二条路:
subst.c:3441 do_compound_assignment→arrayfunc.c:700 assign_compound_array_list逐元素经bind_assoc_var_internal/bind_array_var_internal调钩子;标量绑定走
bind_variable_internal的 assign_func 臂、以 key"0"调钩子(variables.c:3140),
+=标量先make_variable_valueASS_APPEND 读现值拼接(variables.c:3328)。非追加复合形只换 cell
投影、从不清属主表——列表外属主条目保留。declare / typeset /
export 的操作数绑定同走 bind_variable 家族、钩子同路。
rubash 侧:#3107 的
sync_dynamic_assoc_vars只在「属主 → 镜像」方向发布;整表赋值落通用路径只写镜像 + typed 存储,下一命令边界
sync_dynamic_assoc_cells对账时以未被触碰的属主表重建两者,赋值被丢弃。对照 DIRSTACK 早有属主落点门
apply_dirstack_assignment,assoc 对偶一直缺位——本 PR 补上。
普查(全部动态变量整表赋值落点,GNU 探针 27 格实测)
[k]+=)declare / typeset / export 三门与 local 影子、unset 后整表赋值的
基底行为由车道普查对基底二进制逐格核对后回填(见
~/workspace/fix-3211/REPORT.md§2,工作区文件不入仓)。修法
apply_shell_assignment_inner在 DIRSTACK 臂旁加动态 assoc 门apply_dynamic_assoc_assignment(dynamic_arrays.rs,与 DIRSTACK门同居):复合形经与通用路径同一
rewrite_compound_element_subscripts+append_assoc_value扫描后逐条路由属主(aliases 表 /
set_hashed_path);=形以空表为扫描种子(列表内追加在本列表内组合)、
+=形以属主现表为种子算终值且只路由列表点名的键;标量形 = key
"0"单条,+=先读属主[0] 拼接。门控与 DIRSTACK 同口径:readonly 由上游臂先行拒绝,
unset 标记 / local / tempenv 影子让位普通 cell。收尾统一
sync_dynamic_assoc_vars()发布。回归钉
tests/issue3211_dynamic_whole_assignment.rs:普查每个动态变量的整表赋值形 + 元素赋值回归锁 + unset 后普通变量锁,
先行提交(fail-first 核验数字待构建槽腿落地后回填本节)。
本 PR 删除了什么
无删除:纯新增(赋值门 + 回归钉)。通用路径对这两个变量名的整表
赋值自本 PR 起不可达(由门接管),但代码不删——影子/unset 情形仍
走通用路径绑定普通 cell。