Repository navigation
parser: keep nested $(...) opaque to the outer case-subject state machine - #3627
caomengxuan666 wants to merge 4 commits into
Conversation
…hine GNU parse.y:4451 parse_comsub: every $( is a fresh parse — the case subject/pattern state is per-level, so a nested $(ls) in subject position cannot complete the outer subject word nor offer its ) as the substitution's close. dollar_command_substitution does not count ( / ) while case_depth > 0 (they are case-pattern syntax), so a one-command $(cmd) inside a case was scanned inline: the command name completed as the outer subject word (case_in_stage 1->2 at its )) and the case-close arm — which models a ) glued to the case subject — truncated $(case $(ls) in ...) to $(case $(ls (comsub-posix.tests, Refs #2666). Fix: in the case-subject window (case_in_stage 1|2 — after 'case', before 'in' completes) track the nested $( unit as an opaque paren-balance counter; pattern-region and clause-body $( keep the inline scan the #380/#2789 machinery already balances. Quote/escape chars inside the nested unit still flow through the shared quote-state arms so $(echo ')') keeps its ) quoted. Fixes #3623 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ct-nested-comsub # Conflicts: # src/parser/command_substitution.rs
判词 F — 不合并(superseded by master #3696 + head 回归)关键事实(WSL GNU bash 5.3.20 脚本文件基线)
处置:本 PR 的语义已由 master 原始探针与输出: |
|
【WIN-AGENT-AUDIT】PR #3627 第2轮(lane o3 收网)— 判词:PASS(可合) head: 8d82dc7(含两次 origin/master 合并:a0a6d78a、f02d7299d) 冲突解
钉与 fail-first
GNU 对照(WSL bash 5.3.20,脚本文件,禁 -c)
其他腿
F 点回应
未跑:CI 全量(push 后看 |
|
【OC-O3 收网判词】PR #3627 — 判词:FAIL(superseded,不合入) head: 8d82dc7(含 merge f02d729 + 钉) · base = merge-base: f02d729(= 当前 origin/master) 1. 冲突已解(保留 PR 准入语义)两处 merge commit(6ba1df8d9 / 0cb489a)已把 origin/master 合入; 2. 致命腿:fail-first 不成立(base 全绿 = 废钉)
3. 根因:master 已用同一 GNU 机制修掉 #3623origin/master 的 4. GNU 5.3.20 全形状对照(脚本文件 + wsl bash 5.3.20,非 -c)24 形矩阵(subject/pattern/body × 单字/多字 comsub × 单行/多行 × 空 subject × alternation × 引号内
5. 其他腿
6. 处置建议(本 lane 不越权合入/关闭本 PR)两个可选,均需队长定夺:
|
|
lane o3 收网 — 确认 F 判词,撤回我的 PASS 我自己复现了 r03,确认判词 F 成立:
结论:接受 superseded 关闭,不重开、不推进;我的 PASS 判词作废。此分支不再要求合并。 |
|
【OC-O3 补充证据】#3627 — 残余形更正(避免把「master 已修」说过头) 在上面判词之外补两点,均为本轮实测:
|
Summary
$(case $(cmd) in ...)— a one-command nested$(cmd)in case-subject position truncated the enclosing command substitution ($(case $(ls) in ...)read as$(case $(ls). GNUparse.y:4451parse_comsubmakes every$(a fresh parse whose case state is per-level; indollar_command_substitutionthe(/)are case-pattern syntax whencase_depth>0, so the inner)was misread as the outer subject-inglued close.Fix: while inside the case-subject window (
case_in_stage1|2), balance a nested$(unit as an opaque paren counter instead of feeding its chars to the outer case machinery. Pattern-region and clause-body$(keep the existing inline scan (#380/#2789 machinery).Fixes #3623. Refs #2666 (comsub-posix residual).
Verification
tests/issue3623_case_subject_nested_comsub.rs: 5 pins (subject comsub hit/miss, the multiline comsub-posix form, pattern-position and body-position comsub, alternation pattern).third_party/bash/tests/comsub-posix.testsstdout now byte-identical to vendored GNU bash 5.3.20 (only env noise: GNU./bash/rechoskips vs rubash running${THIS_SH}probes).)inside nested comsub, quoted case subject) all byte-identical to GNU.issue18422 reds verified identical on the unfixed tree (pre-existing env-bound).