Skip to content

fix(lexer): let inner dollar words own the EOF verdict inside [ subscripts - #3703

Merged
caomengxuan666 merged 3 commits into
masterfrom
devin/subscript-inner-dollar-verdict
Nov 18, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
devin/subscript-inner-dollar-verdict

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

The [ subscript inner scan of unclosed_array_subscript_walk tracked quotes and [/] depth only, reading $(/${/` bytes literally. An EOF inside a dollar word nested in the subscript was therefore reported as the outer ]`' verdict — v[a=$(x → matching ]' — instead of the innermost pending construct's (`matching `)').

GNU anchor: inside parse_matched_pair(P_ARRAYSUB) a $(/${/$[ after $ (LEX_WASDOL) takes the parse_dollar_word route (third_party/bash/parse.y:4140-4141) — the inner construct owns its own scan, so a ] inside it never closes the subscript and an EOF inside it produces the inner diagnostic. Balanced $(/${/` units are now skipped atomically in the [ scan (src/lexer/skip.rs, mirrored in subscript_residuals_advance in src/lexer/continuation.rs); an unclosed inner unit returns None so the generic close-char path — which already names the innermost pending construct — owns the verdict.

Effects verified against GNU bash 5.3.20 (file mode):

  • v[a=$(x / v[a=$( → )' at the EOF line (was ]' at the [ line)
  • v[a=${x → }' at the ${ line (was ]')
  • v[a=x→ ``'; `v[a=$((1+` → )'(was]'``)
  • v[a=$(x])z keeps ]' at line 1 — the comsub is balanced, its ] does not close the subscript
  • v[a=x]ykeeps]'`` — balanced backquote unit skipped atomically

Exit status: the $( class already matches GNU (2). The word-internal matched-pair status (1 vs 2) is owned by the exit-status split on devin/eof-wordpair-exit-status; the new pin file asserts message + line for all shapes and pins the exit code only where already correct on master.

Regression: cargo test --lib lexer:: 108/108; focused subscript files (issue532/536/2595/1555/2605) green except one env-bound failure (ls exec — the uncommitted Mach-O overlay is not on this branch; GNU baseline unaffected).

Refs #3605

…ripts (Refs #3605)

The [ subscript inner scan of unclosed_array_subscript_walk tracked
quotes and [/] depth only and read $(/${/` bytes literally, so an
EOF inside a dollar word nested in the subscript was reported as the
outer ]' verdict (`v[a=$(x` -> "matching `]'") instead of the
innermost pending construct's (`matching `)'").

GNU anchor: inside parse_matched_pair(P_ARRAYSUB) a $(/${/$[ after $
(LEX_WASDOL) takes the parse_dollar_word route
(third_party/bash/parse.y:4140-4141) — the inner construct owns its
own scan, so a ] inside it never closes the subscript and an EOF
inside it produces the INNER diagnostic. Balanced $(/${/` units are
now skipped atomically inside the [ scan; an unclosed inner unit
defers the verdict to the generic close-char path, which already
names the innermost pending construct (`v[a=$(x]` keeps its ]'
because the comsub is balanced). The continuation residual mirror
(subscript_residuals_advance) gets the same unit awareness plus the
$' quote state the oracle already had.

Verified byte-for-byte against GNU bash 5.3.20 on an 18-case matrix
(inner constructs x unclosed/balanced x report line and exit class);
the word-internal matched-pair exit status (1 vs 2) lands with the
exit-status split on devin/eof-wordpair-exit-status, so the new pins
assert message and line and pin the exit code only where it is
already correct on master.

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

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】PR #3703 第1轮 — 建议:PENDING(内容腿全绿;两处阻塞:命中队长专属文件、fmt 未过)

head: 431e113 base(merge-base): 96802ca 文件: 3 个 +185/-2
关联 issue: #3605(状态:open,我核过的时间:2026-11-16 本地)— 伞目录 issue,PR 只 Refs,不关单。

机制核查:

  • 根因与 GNU 语义属实:third_party/bash/parse.y:4131-4133((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_WASDOL) && (ch=='('||ch=='{'||ch=='[') → goto parse_dollar_word)表明 [ 下标匹配对内的 $(/${ 由内层构造自己的扫描拥有;PR 的 skip.rs 侧修复(unclosed_array_subscript_walk 原子跳过已闭合的 $(/${/backtick,未闭合则返回 None 交给通用 close-char 路径命名最内层构造)与该语义一致;continuation.rs 的 subscript_residuals_advance 是同一 face 的镜像,另补 $'...' 的 q_ansi 态。
  • 实测 12 形状(脚本 target/audit-s5/p3703/p1..p12.sh)GNU 5.3.20 与本 PR head 在 message + 行号 + 退出码上逐条一致;base 96802ca 在 p1–p6/p8/p9 报外层 ]' 行 1(错),p7/p10 把已闭合的 $(...)/backtick 误判为下标结束并把 v[a=...` 当命令执行(rc=127,错)——本 PR 修的就是这两类。
  • 引用小误:PR 与钉头注释写 parse.y:4140-4141,实为 parse.y:4131-4133(parse_dollar_word: 标签在 4169)。另头注释把 $[ 列进「内层构造拥有判决」的清单,但 GNU 5.3.20 实测 v[a=$[x 仍报外层 ]'(rubash head 同);实现未改 $[`,行为与 GNU 一致,只是注释口径偏大。均不阻塞。
  • 阻塞 1(硬规则):diff 修改 src/lexer/continuation.rs(第 4672-4756 行区间),该文件为队长专属(任务书 §1.5:PR 的修复必须动它则停手、报告)。本 lane 不合并、不格式化该文件。
  • 无关改动:无(skip.rs 仅把 skip_braced_unit_scan 提为 pub(crate) 供镜像复用)。

腿(逐项):

  • 钉自跑(head 431e113):issue3605_subscript_innermost_verdict 2 passed / 0 failed。
  • fail-first(base 96802ca,钉文件原样放入):0 passed / 2 failed,红名 = {inner_dollar_word_owns_the_eof_verdict, balanced_inner_unit_does_not_close_subscript},与 PR 声称的两组修复面一致。
  • lib 双边:head {api::consumer_tests::issue2084_session_end_restores_host_process_state}(1350 passed / 1 failed)/ base {同一测试}(1350 passed / 1 failed)/ 差集 ∅(env flake,单跑可过)。
  • -D warnings:RUSTFLAGS="-D warnings" cargo check --locked --lib --bins → 0 警告。
  • 卫生:rustfmt 未过——per-file rustfmt --check 与 WSL cargo fmt --check 同报 3 处:src/lexer/continuation.rs:4720、src/lexer/skip.rs:3129、tests/issue3605_subscript_innermost_verdict.rs:60(均为排版差异,无语义);marker-lint OK (117 registry consts, 268 allowlisted);utf8-boundary clean。
  • CI(head 431e113, run 43735903798 / 43735903793):红任务 4 个,逐个归因——
    • Rust tests、Rust tests (macOS)、GNU regression goldens and canaries:唯一红格 api::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell(1351 passed; 1 failed)= 已知基线 issue2875;
    • niubash builds against this tree:check-api-ledger 报 MISSING session-method rubash::api::Session::cwd,本 PR 未动 api 面;master 已由 58eeb88c docs(ledger): record Session::cwd (#3704) 记录,master run 43856186007 该 job 绿 → 归因 stale-base/CI 货币性。
  • GNU 对照(WSL /usr/local/bin/bash 5.3.20(1)-release,脚本文件形态):
    • v[a=$(x → GNU line 2 ... )' rc=2 / head 同 / base line 1 ... ]';
    • v[a=$( → GNU line 2 )' rc=2 / head 同 / base line 1 ]';
    • v[a=${x → GNU line 1 }' rc=2 / head 同 / base ]';
    • v[a= + 反引号 → GNU line 1 'rc=2 / head 同 / base]'`;
    • v[a=$((1+ → GNU line 1 )' rc=2 / head 同 / base ]';
    • v[a=$(echo y\n echo z → GNU line 3 )' rc=2 / head 同 / base ]';
    • v[a=$(x])z、v[a=$(x)y、v[a=$(x))x、v[a= + 反引号 + x]y + 反引号 → GNU 均 line 1 ]' rc=2 / head 均同 / base 前两条把行当命令执行(rc=127);
    • v[a=$[x、v[a=$[x] → GNU line 1 ]' rc=2 / head 同 / base 同。

F 点:无(语义面无 FAIL 点)。

阻塞项(不合并的原因):

  • B1:diff 触 src/lexer/continuation.rs(队长专属,任务书 §1.5)→ 需队长本人裁断/合并;
  • B2:rustfmt 3 处未过(含 continuation.rs,本 lane 不得改),pre-commit hook 会拒;需在队长侧 cargo fmt 后重跑。

续作记录:无(未改代码;PENDING 不合不关)。
未跑/VOID 的腿:无。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
u4 波批次汇总(9 条全部处理完毕;判词均为建议,合入/关单由队长裁定)

PR 关联 issue 建议判词 终态 / 阻塞
#3705 #2664(closed) PASS extglob 半边真修复;bracket 半边已按 GNU 源回退+BRACKMATCH 毒化层;issue 已 closed,合并与否队长裁量
#3703 #3605(open 伞) PENDING 命中队长专属文件 + fmt 未过,两处阻塞未解(本条为汇总载体)
#3702 #3026(closed by #3708) PENDING(superseded) 建议 owner 关闭本 PR 不返工
#3700 #3032(closed by #3709) PENDING(superseded) 建议 owner 关闭本 PR 不返工
#3685 — PENDING 仍 CONFLICTING/DIRTY,head 未推进,内容腿结论不变
#3672 #3605(open 伞) PASS 第2轮:已 rebase 合入 master(API 等价推送 cbc0b02,tree SHA 核验一致),钉 fail-first 有效,CI 全绿除基线 goldens 双红+census 收尾中
#3670 #3605(open 伞) PASS 第2轮:Session API 钉替换无效 CLI 钉(45269c24e 已推),fail-first 2/2 红名一致,CI 红全部归因基线
#3653 #2983(open) PENDING 机制面已被 master #3049 journal-gate 覆盖(钉在 master 上已绿),去留需队长裁定
#3652 #3300(open) PENDING 编译已修+本地全腿绿;CI 腿 VOID——CONFLICTING 使 pull_request synchronize 不派发 check-run;#3049 FORK_TRANSPORT_KEYS 与 proof 段为语义相邻冲突,已 abort 待队长裁定解法

阻塞项汇总:

  1. fix(lexer): let inner dollar words own the EOF verdict inside [ subscripts #3703:队长专属文件命中 + fmt——需队长处理或改派。
  2. fix(builtins): typeset listing hides unmaterialized BASH_ARGV0 and renders GROUPS from its cell (Refs #3026) #3702/fix(executor): expand coproc NAME before the identifier check (Refs #3032) #3700:等 owner 关 PR。
  3. fix(mapfile): run -C callbacks on mapfile's own input stream (Refs #3660) #3685:CONFLICTING 未解。
  4. fix(executor): keep __RUBASH_*_VARS attribute transport off the exec boundary (Refs #2983) #3653:机制冗余,等队长裁定关闭或保留加固。
  5. fix(executor): adopt respawn provenance via fd/pipe proof for subreaper orphans (Refs #3300) #3652:merge conflict(init.rs provenance 决策点已前移 + compound_exec test helper 重构)需语义合并;合并后 CI 方能派发。

环境备注:本机 git→github.com:443 被断(DNS 投毒),#3672 的两个 commit 经 GitHub Git Data API 重建推送(逐 tree SHA 与本地核验一致,ref fast-forward 更新,未改写历史)。

@caomengxuan666

Copy link
Copy Markdown
Member Author

【WIN-AGENT-AUDIT】
Z3 波批次汇总(收网第四轮,6 条全部处理完毕;判词均为建议,合入/关单由队长裁定)

master 尖(本轮 fetch):a0a6d78ad(会话期间 e480799 → a0a6d78,#3832 PATH tilde,与本批无关)

PR 关联 issue 建议判词 终态 / 阻塞
#3703 #3605(open 伞) PENDING 阻塞未解:diff 触队长专属 src/lexer/continuation.rs(§1.5 本 lane 不得动)+ rustfmt 3 处未过(含 continuation.rs)。本轮复核:head 431e113 未变,git merge-tree origin/master 对 a0a6d78 无冲突;内容腿结论沿用第 1 轮(钉 2/2、fail-first 2 红名一致、GNU 12 形状逐条一致)。需队长本人处理 fmt/合入裁量。
#3702 #3026(CLOSED) PENDING(superseded) 本轮复核 04495715 ∈ master、issue closed/completed → 已发评论建议 owner 关闭,不返工。
#3700 #3032(CLOSED) PENDING(superseded) 本轮复核 b2894ac9 ∈ master、issue closed/completed → 已发评论建议 owner 关闭,不返工。
#3685 #3660(open) —(跳过) 按 §1.4 跳过:x4 车道 2026-11-17T02:38Z 发「续作开工(第 3 轮)— 目标:解 CONFLICTING」,距今 <24h 属在飞车道;head 15be88b 未变。
#3653 #2983(open/reopened) PENDING 本轮复核:master journal-gate(0a405d8a0/#3736,readonly_functions.rs:406-444)仍在且比本 PR 谓词更宽;merge-tree 仍 CONFLICT(同文件)。已发评论建议 owner 关闭(issue #2983 保持 open,残余面另案)。
#3652 #3300(open) PENDING 本轮实做 git merge origin/master(a0a6d78a)→ CONFLICT ×2。init.rs 为语义冲突已 abort:master #3049 把 provenance 判定前移到 from_values/strip 之前,本 PR proof 第三臂必须重锚到早判定点(冲突标记外的 master 新代码),属语义再锚定非机械解;compound_exec.rs 冲突本身机械(proof-mint 块 + test_rubash_binary_from_env())。详见该 PR 第 3 轮评论,需队长裁定 rebase 方式。

本波无 PASS→merge 执行项;无代码改动、无 push。跳过项:#3685(车道在飞)。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 18, 2026 08:30
@caomengxuan666
caomengxuan666 merged commit 35d06fb into master Nov 18, 2026
10 of 12 checks passed
@caomengxuan666
caomengxuan666 deleted the devin/subscript-inner-dollar-verdict branch November 18, 2026 08:31
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