Skip to content

[待队长 diff 复核] extglob 组与 case-first comsub 提取(#2647/#2680/#2784) - #3241

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/CONT-continuation-wave
Nov 10, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/CONT-continuation-wave

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

CONT 专波(continuation.rs 经队长授权由本车道改动,REPORT 逐 hunk 列明,等待逐行复核)。

三单同根:文本层扫描器在真实解析器之前自行其是——extglob 组被下标猎取误截、case 序言未完的 ) 被提取层吞至 EOF、未闭合 extglob 组让同行前段先行执行。

改动要点(GNU 锚点见提交信息与代码注释):

  • 下标残差扫描补 extglob 组消费臂,与 skip.rs oracle 共用 skip_extglob_group_chars;闭合组永不开 P_ARRAYSUB 猎取,未闭合组停放给 close-char 扫描的 ) 裁决。
  • 全部提取机(skip.rs oracle、Lexer::skip_cmd_subst、continuation 两孪生)新增 case_pattern_seen 见证:当前模式表 arm 以来未见模式内容时,) 恢复为单位闭合符,体交回体解析器(parse.y:4451)。
  • close-char 双机在 live extended_glob 门下认领未闭合 extglob 组为待决 matched pair,driver 整行抑制;下标 walk 以单位入口门(live gate)播种 extglob 镜像;run_source_impl 把 parse-error 单位的状态记为其 $?,不再沿用上一单位的陈旧退出码。

验证(Simular box,基底与头侧同环境对跑):钉 fail-first 三单全红(基底逐茎 1/2、1/2、3/2 过/红),头侧 3/3、3/3、5/5;lib 1207/1207;邻茎 12 茎中 10 全绿,issue160 与 issue1555 两茎的红与基底逐名一致(存量环境形,非本 diff);RUSTFLAGS="-D warnings" lib+bins rc=0(--all-targets 唯一错误在未触碰的存量 tests/issue2078 文件);cargo fmt --check rc=0;marker lint OK。

Refs #2647
Refs #2680
Refs #2784

本 PR 删除了什么

无删除。本 PR 仅新增钉文件三份、并在三个源文件内做增补与一处播种值更正(下标 walk 的 extglob 初始值由恒假改为单位入口 live gate);未删除任何既有代码路径、文件或测试。

…e-first comsub)

Three pin files, expectations measured against GNU bash 5.3.20 in
script-file mode:

- issue2647: an unbalanced `[` inside an extglob group is literal
  pattern text (parse.y:5466-5489 read_token_word hands the group to
  parse_matched_pair; lib/glob/sm_loop.c BRACKMATCH) — the script
  runs to completion, no `]`-EOF truncation.
- issue2680: an unclosed extglob group kills its whole command list
  before any segment executes (parse.y:3901-3912), while a parse
  error on a later line leaves earlier lines executed.
- issue2784: `$(case x in)` / `$(case x)` reach the body parser,
  whose diagnostic names the paren (parse.y:4451 parse_comsub);
  valid and empty case bodies keep extracting.

Refs #2647
Refs #2680
Refs #2784
…the real parser

Three mechanisms, all GNU-anchored:

1. Extglob groups are word text (parse.y:5466-5489 read_token_word:
   a word-final PATTERN_CHAR, syntax.h:92, hands the balanced group
   to parse_matched_pair, parse.y:3877). The subscript residual scan
   gains the same consumption arm the skip.rs oracle carries
   (skip_extglob_group_chars, now pub(crate) and shared): a closed
   group never opens a P_ARRAYSUB hunt (parse.y:5635-5643), an
   unbalanced one parks at the `(` for the close-char scan's `)`
   verdict instead of truncating the script at a phantom `]`.

2. A case preamble that is still unfinished when `)` arrives is
   rejected by the BODY parser under GNU (parse.y:4451
   parse_comsub), so every extraction machine (skip.rs oracle,
   Lexer::skip_cmd_subst, and the continuation twins) gains a
   pattern-content witness, case_pattern_seen: no pattern seen
   since the list was armed (`in`, or a `;;`-family re-arm) means
   the `)` closes the unit and the body parser names it.

3. An unclosed extglob group at the main level is a pending
   matched pair (parse.y:3901-3912): the close-char scans (one-shot
   and parked twin) claim it under the live extended_glob gate, so
   the driver suppresses the whole opener line instead of streaming
   its earlier `;`-segments into execution. The subscript walk now
   seeds its extglob mirror from the unit's entry gate (the live
   gate, pinned per gathered group) instead of assuming off, and
   run_source_impl records a parse-error unit's status as its $?,
   which the unclosed route previously only returned — a grouped
   reader therefore no longer inherits a stale exit code.

Refs #2647
Refs #2680
Refs #2784
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 10, 2026 11:54
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