Repository navigation
fix(parser): quoted parens are not a function-definition head (Refs #3388) - #3744
arookieofc-ai wants to merge 1 commit into
Conversation
…3388) The function-definition probe matched the '()' head by token value only, so the quoted words '(' / ')' / '()' (ordinary Word tokens) were mistaken for the WORD '(' ')' head. The probe then demanded a '{' body and reported a syntax error at whatever followed, aborting the whole script: '[ '(' ')' died at ';' instead of reaching the '[' builtin, which must report '[: missing ']'' (status 2) at runtime and let the script continue, as GNU does. Gate the paren shapes on genuine operators (is_keyword / unquoted raw text).
|
Thanks for the PR — and for the thorough write-up and GNU comparison. First-pass review (intake, not a merge verdict — the captain reviews external PRs first):
One thing the captain will need to decide: #3388 already has an in-house implementation in flight — PR #3558 (owner, Queued for captain review; CI watched. Thanks again. |
|
队长裁决(#3388 双在途):先行实现 = #3558,本 PR 暂缓、不关闭、不并行改产品面。 核查依据(队长逐 hunk 对照两支 diff + 按名两支 CI):
本 PR 的存活价值:钉文件保留并将被吸收。tests/issue3388_unclosed_bracket_regressions.rs(247 行)比 #3558 的钉(107 行)覆盖更广,两套钉文件名不冲突、可并存。#3558 合入后,请将本 PR rebase 为只留钉文件(产品 hunk 丢弃),队长按 fail-first(在未修尖 e3a7b7b 上红、合并尖上绿)复核后合入,作者署名保留。在此之前请勿自行 rebase 或关闭本 PR(与首评口径一致)。 #3558 的下一步在队长侧:update-branch 到现尖 e3a7b7b 后重跑 CI 按名 + 队长复核,再合入(其正文为 Fixes #3388,合入即关单)。 |
|
【WIN-AGENT-AUDIT】PR #3744 第2轮 — 建议:PENDING(钉已验证可吸收;产品面被已合入的 #3558 覆盖,按队长既定口径 rebase 为只留钉) 机制核查:
腿:
F 点:无(判 PENDING 系队长已裁暂缓 + #3558 已合入后的吸收路径,非质量问题)。 说明:本 PR 正文无「删除了什么」一节(产品 diff 仅替换判定式,-14 行),属正文卫生小疵,不影响判词。 未跑/VOID 的腿:无。 |
|
评审结论:SKIP — superseded(重复实现),不合入,不关闭。
master 侧的实现已经更完整:统一谓词 证据(在本评审 worktree,detached + merge
下一步建议:关闭为 duplicate 由人工决定(本车道不关闭 PR);若 |
|
【P1 车道复核】PR #3744 — 判词:SKIP / superseded(当前 master 已用 #3558 的实现修掉同一缺陷,本 PR 的修法与 master 在同一 hunk 语义冲突)
覆盖核验:本 PR 的测试在 master 上全绿把本 PR 的 即本 PR 想钉的行为(含 未关闭 PR / 未关闭 #3388(保持 OPEN)。 |
|
【WIN-AGENT-AUDIT】 机制核查:
钉增量核查(本轮核心,决定 合钉/关/补形状):
腿:
F 点:
未跑/VOID 的腿:钉对当前尖 ccb8614 未重跑(理由见上,function_command.rs 零漂移);其余无。 |
|
Thank you for this fix — the root-cause analysis is right, and the same mechanism landed via #3558 (filed 2026-11-14, a day before this PR, and merged 2026-11-16): the probe now matches parens on the operator token ( Your regression suite is not lost: it covers four shapes #3558's own pins lack (closed-bracket runtime error, |
The fix for #3388 landed via #3558 (same operator-token mechanism). #3744's pin file adds four coverage shapes #3558's pins lack: the closed-bracket runtime error, !/test forms, unquoted-paren parse-error preservation, and the unclosed [[ guard. Pin file taken verbatim from #3744, authorship preserved. Co-authored-by: arookieofc-ai <[email protected]>
Root cause
The function-definition probe in
src/parser/function_command.rsmatched the()head by token VALUE only, so the quoted words'('/')'/'()'— ordinaryWordtokens whose dequoted value is(/)/()— were mistaken for theWORD '(' ')'function head. The probe then demanded a{body and reported a syntax error at whatever followed (;,], the next word, or EOF), aborting the whole script.Reproduction (before the fix)
GNU (bash 5.2.21 here; the issue was filed against 5.3.20, same behaviour) treats
[as an ordinary builtin: missing]is only a runtime[: missing]'' error, status 2, and the script continues.Fix
Gate the paren shapes in
parse_function_command_with_diagnostic(admission, compact/separated(), and the!!reassembly) on genuine operators:is_keyword(kindKeyword) for(/), and unquoted raw text (raw == value, the codebase's unquoted idiom) for a lone()token — the lexer never emits an unquoted single()operator token, so that arm previously could only ever fire on quoted words.Verification (box, GNU bash 5.2.21 baseline)
-cform printsrc=2, overall rc 0, stderr[: missing]'' — byte-identical behaviour to GNU.echo '(' ')',echo '()'), closed[with quoted parens is a runtime test error,!/testforms, and — unchanged — unquoted parens still parse-error at the same token GNU blames ([ ( a = a ),[ a ( b ],echo (),[ ( ) ]), unclosed[[ ]] still a parse error, and all three function-definition spellings (f() {},f () {},function f() {}`) still define and run.cargo test --lib: 1249 passed, 0 failed (4 ignored). Note: with--test-threads 2the run showed one failure inissue2084_session_end_restores_host_process_state, which passes in isolation and single-threaded — that test's own comment documents it is only deterministic with no overlapping sibling session era, so this is its known parallelism sensitivity, not a regression.audit_a1_parser_regressions(7),issue1041,issue1154,issue1275,issue1610(3), plus the new suite below (8).cargo fmt --check,git diff --checkclean.tests/issue3388_unclosed_bracket_regressions.rs(8 tests: seed,-cform, quoted parens as plain words, closed-bracket runtime error,!/testforms, unquoted-paren parse errors, unclosed[[still a parse error, function definitions still work).Refs #3388