Skip to content

fix(executor): nameref substring diagnostics carry the varname label (Refs #3296) - #3928

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/3296-nameref-substring-diag-label
Nov 19, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/3296-nameref-substring-diag-label

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

rubash #3296: ${v:ref=1:2} — the diagnostic for a failed nameref offset/length bind lost its v: label (GNU prints it; value and rc were already identical).

Root cause (GNU first): parameter_brace_substring swaps this_command_name to the written varname around verify_substring_values (subst.c:9050-9075, :9372), so builtin_error_prolog (builtins/common.c:83-95) prints <script>: line N: v: \1': not a valid identifier. rubash records the diagnostic in the thread-local arith event log but never stamped it with the varname label — and probe/scan parses leaked their events into the real expansion's drain, so the same face also printed duplicates, misplaced lines, or nothing at all (&self` path never drains).

Fix:

  • arithmetic/mod.rs: mark/truncate helpers for the event log (probe discipline; no new public API).
  • parameter_core.rs: scan parses clear their events after judging (bad array subscript 诊断在非字面/模式/子串展开形翻倍(4 次 vs GNU 2 次;#2527 同族残面) #3225 precedent — a probe judges truth, it does not report); an operand that IS a $(( ... )) expansion evaluates under the NULL label window (subst.c:10873-10878) in both &self and &mut paths; (...) keeps the label.
  • arrays/executor.rs: array_at_word_values marks the log before its substring probe and truncates on non-claim, so only a claim owns the diagnostics.
  • Pin A3 corrected: the length-operand cell now declares the nameref — without declare -n ref, GNU binds ref=1 silently and prints no diagnostic (oracle-checked 2026-11-19 by the continuation lane).

Pins: tests/issue3296_nameref_substring_diag_label.rs, 14 cells (A1–A14; A9/A14 are the $(( )) no-label controls). Fail-first on the old tip: 12 red / 2 green (the two controls). The continuation lane re-verified the A3 correction against the GNU 5.3.20 oracle directly.

Residual (REPORT §2.3, not this PR): a[@]/@ in echo drop an offset write (i+=1 stays 0 in rubash; GNU applies it, i=1) — a separate write-loss face, to be filed by the continuation lane with GNU + rubash evidence.

Refs #3296

本 PR 删除了什么

无。

@caomengxuan666

Copy link
Copy Markdown
Member Author

队长复核:可合(头 16e57d8;合入次序见下)。

头 CI 逐名裁定(run 44365529329):census 79,自带钉 14/14 绿(fail-first 12 红 / 2 绿,见 REPORT §4);新增两格皆为既判抖动族(issue2340 wait/jobs 时序、issue2883 read 提示——本修法触及算术诊断日志与子串探针纪律,执行不到该面);goldens 基线二名(232 passed);CLI 仅 coproc 抖动格;其余全绿。服务器腿已齐(REPORT §7.4:钉 stem 14/14、-D warnings rc=0、四文件 rustfmt 全过、lib 1280/1280 零差)。

合入次序:#3913 先合(已合,5880bd40)——#3913 的 lane 提交亦改 arithmetic/mod.rs,本 PR 同文件须 rebase 到新尖 db580be 后再合;rebase 后若 CI 代次变了,队长按新头重裁。§2.3 写丢失残差已证为 phantom(REPORT §7.5:五形在基底与修后树上均为 i=1),不另立案。

Fail-first pin only; fix blocked on file-level guards (see REPORT).
No product code changed in this commit.
…(Refs #3296)

GNU's parameter_brace_substring swaps this_command_name to the written varname around verify_substring_values (subst.c:9050-9075, :9372), so a failed offset/length bind prints 'v: `1'"'': not a valid identifier'. rubash recorded the diagnostic in the thread-local arith event log but never stamped it with the varname label, and probe/scan parses leaked their events into the real expansion's drain (duplicate/misplaced/zero prints).

- arithmetic/mod.rs: mark/truncate helpers for the event log (probe discipline).
- parameter_core.rs: scan parses clear their events after judging (#3225 precedent); operands that ARE a $((...)) expansion evaluate under the NULL label window (subst.c:10873-10878), in both &self and &mut paths; (...) keeps the label.
- arrays/executor.rs: array_at_word_values marks the log before its substring probe and truncates on non-claim, so only a claim owns the diagnostics.
- Pin A3 corrected: the length-operand cell now declares the nameref (without 'declare -n ref' GNU binds silently and prints no diagnostic; oracle-checked 2026-11-19).
@caomengxuan666
caomengxuan666 force-pushed the fix/3296-nameref-substring-diag-label branch from 16e57d8 to 9c21e6c Compare November 18, 2026 23:51
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 19, 2026 00:04
@caomengxuan666
caomengxuan666 merged commit 5eed057 into master Nov 19, 2026
10 of 12 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 19, 2026
… shape (Refs #3936)

fix(parser): return latched loop body/condition errors instead of EOF shape (Refs #3936)

## 根因
`parse_loop_body(...)?` 的 None 臂把体部已锁存的错误吞回 EOF 形:`while`/`until`
体部算术参数在 EOF 处报错时,解析器丢弃了 `compound_body_parse_error`
已锁存的错误,报成 `while`/`until` 控制词缺失。#3184 缺陷 B(if 形)
的同族,另一文件(loop_command.rs)。GNU 锚:parse.y:6724/6841、:4896/4926。

## 修法
三处锁存错误丢失点改为同形直接返回 `compound_body_parse_error`
(loop_command.rs),不改任何其他语义。残差 w7(`while x; do do echo hi; done`,
GNU 点名 `do`、本品点名 `done`)有意不钉。

## 本 PR 删除了什么
无删除。本 PR 为纯加法:3 处直接返回 + 1 个新回归钉文件
(tests/issue3936_while_until_body_latched_error.rs,18 格);
队长卫生提交 3090347 仅做 rustfmt 空白对齐。

## 队长裁定(头 3090347,CI run 44470616506;服务器腿 run-3936 + run-3936-resume)
- 钉:CI 普查里 issue3936 stem **18/18 PASS**;服务器 fail-first base 树
  **8 passed / 10 failed**(10 个 latched-error 形态全红,与预期逐格一致)。
- 服务器腿:探针矩阵 **20/20 SAME**(对 GNU 5.3.20 oracle);相邻钉
  issue3184 两 stem 21/21 + 7/7、issue3204 7/7 全绿;issue2741_2742 stem
  在 base 树同为 2/7 逐格一致(tip 与本 PR 头的 CI 普查名集均无此 stem)——
  本地 harness 既存形态,非本 PR 回归;lib base 与 fix 均 1280/0/4,
  失败名集双向对齐;`RUSTFLAGS="-D warnings"` rc=0。
- 普查:70 名;较尖(69 名)新增 2 格——issue2029 `head_two_lines_then_read_continues`
  与 issue3633 `dead_coproc_unbinds_after_pipe_read`,二者均在 #3928、#3930-r2
  的头普查里翻红过(其修复到不了这两个面),且本头与零新增的前头 75d014c
  只差一处空白 fmt 提交——按既定普查抖动标准裁为抖动,非回归;尖集里
  issue1902 stdin 格翻绿。
- Goldens 恰好基线 2 名;CLI 仅 1 红——已记录的 coproc CLI 抖动
  `c_command_keeps_named_coproc_output_fds_distinct`;其余腿(Rust tests、
  Shell、darwin、linux/android、Windows 编译、niubash 构建、API ledger)全绿。
- 零交集证明:base 6c8ff4e...尖 e9e3d7a = 26 文件,与本 PR 的 2 文件无交集,
  免 update-branch 合入。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant