Repository navigation
fix(lexer): report compound-assignment ) not ] for a mid-element [ at EOF (Refs #3904) - #3908
Merged
Merged
Conversation
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…t exits 1, not 2 (Refs #3899, Refs #3900) fix(script_driver, lexer): EOF consumed by a compound array assignment exits 1, not 2 (Refs #3899, Refs #3900) #3897 changed the EOF route's arms to return 2 unconditionally. GNU does not: EOF consumed inside parse_compound_assignment's token loop sets EXECUTION_FAILURE (parse.y:7151-7152 diagnostic at the `name=(` line, :7167-7169 set status 1); the `error yacc_EOF` production forces 2 only on a still-zero status (parse.y:484-493), and live errexit forces 2 (error.c:324-327). The three arms (generic close-char, `$[` hunt, extglob) now consult the delimiter stack's array_list bit: status 1 when a compound assignment is open (2 under live errexit), else 2. Captain correction in the same PR (commit 2fc6dad, continuation.rs, captain-exclusive file): the close-char scan's top-level `(` arm classified any command-position `(` with a non-empty pending word as an array list, so `!(` (extglob/negation, pending word `!`) carried a false-positive array_list bit and flipped the issue3229 case-position extglob cell 2 -> 1 on the first head. array_list now requires a genuine `name=`/`name+=` word; other command-position words open a subshell frame. Applied in lockstep to the oracle scan and its checkpointable mirror. GNU probes: `case ab in / !(ab` -> rc 2 line 3; `v=(a +(x` -> 1; `echo +(x` -> 2. Verification (captain-adjudicated, REPORT ~/workspace/fix-eof-split/REPORT.md): - Head census (2fc6dad) total 81 (era band 79-88, better than tip 85): compat_issue78 green (CLI 7/7), issue551-c6 green, issue3229 stem green (10/10 on the server tree). New cells vs the old tip are census jitter on faces this diff cannot reach (issue2333 carrier family; issue3640 x2, already proven jitter by server isolation 7/7 on both trees; issue2340 wait-retention and issue2972 declare-listing, both green on the two immediately preceding heads and unreachable from EOF routing). - Goldens exactly the 2 baseline names. CLI's only fail is the documented coproc flake; the compat_issue78 CLI cell is green. - Server legs on the fixed tree: issue3229 10/10, compat_issue78 7/7, issue551 9/9, 40-shape oracle matrix byte-identical to the lane's fixed matrix, RUSTFLAGS="-D warnings" rc=0, rustfmt clean. - Merged without update-branch under the zero-intersection exception: base(bb27eb2)...tip(cc80b2d) touched only trap_exec.rs + 2 test files; this PR touches only script_driver.rs + continuation.rs. 本 PR 删除了什么: - 未删除任何产品代码、测试用例或钉。本 PR 只改 EOF 状态分流(script_driver.rs 三臂)与 close-char 扫描的 `(` 分类(continuation.rs 双臂);回归钉 tests/issue3229… 的既有断言保持 GNU 真值不变。 UNVERIFIED-BY-CAPTAIN — captain review: PASS. Merge by captain; #3899 and #3900 to be hand-closed by the captain after merge (Refs-only body, no auto-close). Residuals: #3904 (A13, PR #3908 in flight, rc assertions need this merge + rebase) and #3905 (A14, captain's nested-arm fix in continuation.rs, next).
… EOF (Refs #3904) GNU parse.y:5635-5639 admits the P_ARRAYSUB scan only for a pure identifier at a command position (assignment_acceptable) or an element-start [ (token_index == 0 && PST_COMPASSIGN). Inside parse_compound_assignment's token loop (parse.y:7104-7169) the previous element token is a WORD, so a [ after a non-empty word fragment (v=(a[1) is literal word text and EOF falls through to the loop's own ') report (parse.y:7151-7152). The subscript walk's command-position tracking stayed true from input start through the name=( opener, so a[ looked like a command-position identifier and opened a phantom ] hunt. Gate that disjunct on being outside any compound assignment, and treat a newline (or comment-terminating newline) inside the list as an element start, like a space. Nails: tests/issue3904_compassign_subscript_closer.rs (17 diagnostic cases + 3 closed-form guards, GNU 5.3.20/5.3.9 byte-checked). Known follow-ups (not in this commit): the rc-1 assertions need PR #3903's status split (rebase after it merges); the A29 token-error face needs a script_driver.rs arm (guarded by #3903); the continuation.rs subscript mirror needs the same three edits in lockstep (captain-only file) or lib subscript_residual_incremental_tests::incremental_matches_full_randomized stays red.
…ls_advance (Refs #3904) The incremental mirror of unclosed_array_subscript_walk must stay in lockstep with skip.rs: the command-position '[' arm opens a subscript hunt only outside compound assignments (parse.y:5635-5639/3163), and a newline inside a compound assignment ends the current element (so the next empty word '[' is element-start, parse.y:7104-7169). Without this the lib randomized test incremental_matches_full_randomized diverges on ' a x=(\na[\n' (mirror reports an unclosed subscript, the walk correctly returns None). Three parallel changes, mirroring PR #3908's skip.rs edit: the '[' gate gains compassign_depth == 0; the comment-newline and whitespace-newline arms set element_start = compassign_depth > 0 instead of false. All other element_start = false arms are untouched, matching the walk.
caomengxuan666
force-pushed
the
fix/3904-unclosed-diagnostic-fidelity
branch
from
November 18, 2026 12:37
3d17c18 to
4f57131
Compare
caomengxuan666
marked this pull request as ready for review
November 18, 2026 13:13
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
…F split (Fixes #3905, Fixes #3914) fix(lexer): compound assignment inside $(...) takes the compassign EOF split (Fixes #3905, Fixes #3914) Two commits, both captain-authored (continuation.rs is captain-exclusive; the #3905 lane's REPORT localized the defect and handed the file back): 1. The nested `(` arm in both close-char scans (unclosed_input_close_char_ posix + mirror close_char_residuals_advance) recognizes a compound- assignment opener from the raw text — nested_compassign_opener: an identifier or subscripted name directly followed by `=`/`+=` at a command token position (GNU token_is_assignment parse.y:5270/:5653 + assignment_acceptable parse.y:3163, or PST_ASSIGNOK for declare/local/ export/readonly/typeset) — and pushes an array_list frame like the top-level arm's, so the #3903 EOF status split reads it. Suppressed inside an array list (element text, the #3904 A29 family), a case pattern (PST_CASEPAT), arithmetic bodies, and process substitutions. 2. Residual #3914: the scans' in-delimiter escape arm consumed a `\<newline>` pair without advancing the line counter, so every later EOF report in the body named a line one too low (plain-comsub probe: GNU line 3, rubash line 2). Both arms now count the escaped newline, like the stack-empty arm already did. Verification: fail-first on the base tree (pin 2 passed / 1 failed — the fidelity test red, controls green). Fixed tree on the server: pin 3/3, 13 adjacent EOF stems green, lib randomized 8/8, lib full 1280/0, cli_tests 461/10 (the documented pre-existing set: 9 examples cells + the signal-mask trap-listing cell), RUSTFLAGS="-D warnings" rc=0, marker lint rc=0, utf8 hygiene rc=0, rustfmt clean. Head CI adjudicated by name: census 77 (era band; issue3905 stem 3 PASS lines in census, no new failing stems vs the #3908 head), goldens exactly the 2 baseline names, CLI pass, Rust tests pass, niubash-builds pass. 本 PR 删除了什么: - 未删除任何内容。纯新增:raw-text 识别助手三件、两扫描嵌套臂的 compassign 分支、两扫描转义臂的行计数、新回归钉一个文件。
caomengxuan666
added a commit
that referenced
this pull request
Nov 19, 2026
…l (A29) ## 摘要 #3904 的 A29 半:复合赋值列表自身层级的 token 错误此前被报成 EOF 形。`UnclosedComsubShape::CompassignTokenError` 扩为 `{ line, token, in_comsub }`:shape 扫描在复合赋值帧自身层级记录第一个元字符 token(`;`/`;;`/`;&`/`;;&`、`&`/`&&`、`|`/`||`/`|&`、重定向算符、IO_NUMBER 数字串),帧于 EOF 仍开才浮现;script_driver 新增渲染 arm(token 措辞 + comsub/procsub 的 `while looking for matching ')'` 后缀 + 犯行回显;状态 1、errexit 活时 2 且不回显),并在 `command_paren_verdict_disproved_by_parser` 加同型 guard 例外(真 parser 的 EOF marker 不再抢判);trap_exec 的 eval arm 同步渲染 token 与后缀。GNU 锚点:parse.y:7141-7159、:6833-6865、:6858-6859、:7167-7169、error.c:324-327。 ## 队长复核(头 e1511f0) - CI census:自带钉 `issue3904_compassign_token_error` **6/6 全绿**;总集 69(尖集 72 内 68),唯一新名 `issue2340 repeated_bare_wait_keeps_survivor` 裁为 census flake(19 个已存头集全无此格;本 diff 到不了 wait/作业留存面;issue2340 属已判不稳定族)——评论 issuecomment-6998676374。 - goldens 恰基线 2 名;Rust tests / CLI / 交叉靶 / ledger / niu 构建全绿。 - **fail-first 由 CI 自证**:首头 b76cf3b 的 census 里新钉 5/6 红(实况为旧 EOF 文案),guard 修复(e1511f0c)后 6/6 绿。 - 与尖 3638227(#3925 合入)零交集已程序化证明(compare 文件集 ∩ PR 文件集 = ∅),故未走 update-branch。 ## 验证债(明示,按 #3874 先例) 服务器 sshd 自 ~10:35 CST 起不应答,全部构建路线断(X299 隧道亦断、box 休眠)。车道的服务器腿(base-only fail-first 复跑、lib 双边名集、`RUSTFLAGS="-D warnings"` check、逐文件 rustfmt)**仍欠**,腿脚本与 bundle 已备(~/workspace/fix-3904-a29/legs/);路线恢复后由队长补跑销账,账记 dispatch-state.md。lib 面由本头 CI 的 Rust tests 绿 + 全量 census 覆盖;fail-first 由 CI 双头对照覆盖(见上)。 ## 本 PR 删除了什么 trap_exec.rs 中 CompassignTokenError 臂原先写死的 `` `(' `` 措辞被 token 携带的渲染取代;无命令、选项或公开面删除。 Refs #3904(A13 半已由 #3908 合入;本 PR 合入后 #3904 由队长手关)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(lexer): report compound-assignment
)not]for a mid-element[at EOF (Refs #3904)根因
GNU
parse.y:5635-5639只在两种情形下对[开 P_ARRAYSUB 扫描:(a)[前为纯标识符且assignment_acceptable(last_read_token);(b) 元素词首[(token_index == 0 && PST_COMPASSIGN)。parse_compound_assignment的词元循环(parse.y:7104-7169)逐元素read_token,前一元素已是 WORD,故列表内a[1这种 mid-element[是字面词字符,EOF 由循环自己的parser_error (orig_line_number, "unexpected EOF while looking for matching)'")(parse.y:7151-7152)报出行 1、rc 1(set_exit_status (EXECUTION_FAILURE),parse.y:7167-7169`)。rubash 的文本级下标扫描(
unclosed_array_subscript_walk,src/lexer/skip.rs)的命令位臂在name=(开启后仍保持 input-start 的command_position=true,于是a[被当作命令位标识符开 hunt、抢在通用 close-char 路径前报]。另:换行/注释换行臂把element_start一律置 false,使元素首[在换行后也被漏报(v=(a\n[1GNU 报]行 2)。改动
仅
src/lexer/skip.rs(unclosed_array_subscript_walk,+21/−3):[门第一析取加compassign_depth == 0——命令位标识符臂只在复合赋值之外开 hunt;列表内只剩元素首[臂。\n与注释内\n两处):element_start = false→element_start = compassign_depth > 0——列表内换行结束当前元素,与空格臂同规则;列表外恒为 false,行为不变。新钉
tests/issue3904_compassign_subscript_closer.rs:17 个诊断形(措辞/行号/rc)+ 3 个闭合形守卫,逐字对 GNU bash 5.3.20(oracle 矩阵)与 5.3.9 复核。本 PR 删除了什么
未删除任何代码、文件或公开面。行为上删除的只是一处误报:mid-element
[在复合赋值内不再被当作未闭合下标报](v=(a[1、v=(a[1 b[2、v=(a[1\nb等 6 形改报列表的));元素首[(v=([1、v=(a [1、v=(a\n[1)仍报],裸命令位a[1仍报]rc 2,闭合形照常解析。验证(服务器腿)
compassign_subscript_closer_fidelity红在首形v=(a[1报];修后措辞/行号 17/17 绿。issue3605_subscript_innermost_verdict2/2、issue3605_eof_exit_status_word_pairs4/4、issue3605_compound_eof_last_line4/4、issue1184_f4_procsub_diag_line_regressions7/7、issue1184_f6_backquote_eof_regressions26/26。examples::*×9 服务器环境格 +subshell_trap_listing信号掩码格 + regression(#3897): unclosed compound assignment at EOF exits 2, GNU exits 1 (compat_issue78) #3899 钉——该钉待 fix(script_driver): EOF consumed by a compound array assignment exits 1, not 2 (Refs #3899, Refs #3900) #3903,见下)。RUSTFLAGS="-D warnings" cargo check --locked --lib --bins:rc 0。rustfmt --check(两改动文件)干净。待队长(本 PR 合入前的两项依赖,请勿直接合)
subscript_residuals_advance(src/lexer/continuation.rs,队长专属文件)是本 walk 的增量镜像,lib 测试subscript_residual_incremental_tests::incremental_matches_full_randomized强制两者锁步。本改动后该测试红(首个发散输入" a x=(\na[\n":镜像报Some((2, true)),walk 返None)。镜像侧需完全平行的三处改动:[门第一析取加state.compassign_depth == 0(~4793 行);注释内换行臂(~4568 行)与空白换行臂(~4765 行)的state.element_start = false改为state.element_start = state.compassign_depth > 0。队长在该文件落改动后 lib 即绿。本车道按红线未碰该文件。)形 rc 1;当前基底 master(无 fix(script_driver): EOF consumed by a compound array assignment exits 1, not 2 (Refs #3899, Refs #3900) #3903)对复合赋值 EOF 形一律 rc 2,故钉的 rc 断言现为红(措辞/行号已绿)。fix(script_driver): EOF consumed by a compound array assignment exits 1, not 2 (Refs #3899, Refs #3900) #3903 合入后 rebase 到新 master 重跑即绿,无需再改码。证据:同形在已含 fix(script_driver): EOF consumed by a compound array assignment exits 1, not 2 (Refs #3899, Refs #3900) #3903 的树上报 rc 1。未修:A29(同 issue 另一形,另派)
v=(a (echo等 token-error 形(GNU:syntax error near unexpected token \('+ 回显行,rc 1)仍报)。其渲染臂须落在src/script_driver.rs未闭合路由——该文件正由 open PR #3903 占用,按护栏停手。检测器(unclosed_comsub_eof_shape→CompassignTokenError)与渲染/状态模型(trap_exec.rseval 路径)均已存在,#3903 合入后可直接落臂。详见~/workspace/fix-3904/REPORT.md` §5。Refs #3904
UNVERIFIED-BY-CAPTAIN