Repository navigation
fix(lexer): REPL judges gate-released unclosed-case comsub units complete (Refs #3307) - #3756
Conversation
… (Refs #3307) The non-interactive gate (#3303) releases unclosed-case comsub units whose armed pattern region has no content yet, but the three #2784- witness unit scans (Lexer::skip_cmd_subst, skip_parenthesized_unit_ corrected and its staged mirror skip_parenthesized_unit_corrected_ex) carried no equivalent predicate, so the interactive face held separator-tail shapes such as `echo $(case x in a|)` to PS2 while the gate released them. Port the gate/parser arm's per-pattern content bookkeeping (content, paren depth, opener availability, pending-opener count) into all three scans and add the reclassification predicate `(region_before && !content_before)` to their `)` arms. Tests: tests/issue3307_repl_unclosed_case_comsub.rs (fail-first: the two released-family tests fail on the base tree).
|
Thanks for the follow-up to #3303 — this one is queued for captain review (external PRs are reviewed by the captain first, per the owner's rule), with CI watched. A first pass from intake: What I checked: read the full diff (3 files, +415/−6). The change ports the #3303 gate/parser arm's per-pattern content bookkeeping into all three CI status (runs 43787382113 / 43787382157): the only failing test across the Linux, macOS and goldens legs is the same single lib test, Notes for the captain's review: (1) the body says No action needed from you — the captain will review and decide next. |
|
【WIN-AGENT-AUDIT】s2 PR #3756 第1轮 — 建议:PENDING(本 lane 不合并) 不合并原因(规程 1.5 + AGENTS.md 队长专属文件):diff 修改 机制核查:
腿:
F 点:无(若队长接受机制,判词可转 PASS) 未跑/VOID 的腿:
合并:无(PENDING,未关 #3307) |
|
【WIN-AGENT-AUDIT】PR #3756 第2轮 — 建议:PENDING(队长专属文件,本 lane 停手) T 波处置(收尾波,分工 t4):
未跑/VOID 的腿:本轮全部(队长车道停手)。 |
|
【WIN-AGENT-AUDIT】PR #3756 第3轮 — 建议:PENDING(队长专属文件,本 lane 停手) V 波复核(分工 v1):
未跑/VOID 的腿:本轮全部(队长车道停手)。 |
|
评审结论:FAIL(不合入,不关闭)。 阻断项 1:语法错误之后继续执行(新引入,非既有残差)
探针 echo $(case x in a|) $(echo ok)
echo after
即:本 PR 把「解析错误 → 整段不执行」改成了「解析错误 → 继续执行」。PR 正文把这列入 "Known residuals"(" 阻断项 2:修改 captain-exclusive 文件本 PR 改了 已核且通过的部分(供修好阻断项后复用)
下一步
|
|
补充(合入后复测):本 PR 已由 owner 合入 master(
根因指向 |
…mmand (Refs #3756) (#3843) * fix(executor): keep a `$(` body parse error fatal to the enclosing command (Refs #3756) GNU early.md anchor: parse.y:4451 parse_comsub hands the body to the grammar while the word is read; a body grammar failure is yyerror -> jump_to_top_level (DISCARD), so the enclosing input unit is abandoned whole and NOTHING in it executes. Three rubash defects kept that from holding after #3756 released truncated-case comsub units: 1. expand_command_substitution_with_context reset the body-error latch at every substitution entry, so a later substitution in the same word list cleared a fatal `$(` verdict and the command still ran (`echo $(case x in a|) $(echo ok)` printed `ok`, rc 0). 2. The abort in execute_command_with_procsub_scope keyed on last_command_substitution_status == Some(2); that slot is the documented left-to-right `$?` overlay and the next substitution overwrites it with its own child exit (0), masking the verdict. The latch alone now decides (every latch site also sets status 2). 3. The extractor's case machine never armed its pattern region for a plain `case WORD in` (word_boundary false after the subject word), so `$(case x in a|)` scanned as unclosed: the read-time body screen (rubash#2789) saw no node, and a skipped-branch body (`false && echo $(case x in a|)`) was silently ignored instead of killing the unit. GNU special_case_tokens rule 6 (parse.y:3369-3386) makes that `in` a reserved word regardless of boundary and parse.y:3379/3396 arms the region. Verified byte-identical to WSL GNU bash 5.3.20 on 15 shapes x {plain, quoted, assignment, pipeline, and-or-skip, adjacent-word, trailing command} at rc/stdout/stderr; issue3307/2784/2789/3229/435 and the case pins stay green. * test(parser): pin the arming of `case WORD in` in the comsub extractor (Refs #3756) The pattern region now arms at the `in` token (GNU special_case_tokens rule 6, parse.y:3369-3386), so the empty-case shape scans over its whole span instead of running off the end. Executed behavior is unchanged (`echo $(case x in esac)` and its sibling/assignment forms are byte-identical to GNU 5.3.20), so the old scan-level None expectation is replaced with the extracted span and the verified behaviors.
Fixes #3307.
The non-interactive gate (#3303) releases unclosed-case comsub units whose armed pattern region has no content yet, but the three
#2784-witness unit scans carried no equivalent predicate, so the interactive face held separator-tail shapes such asecho $(case x in a|)to PS2 while the gate released them.This ports the gate/parser arm's per-pattern content bookkeeping (content, paren depth, opener availability, pending-opener count) into all three scans and adds the reclassification predicate
(region_before && !content_before)to their)arms:Lexer::skip_cmd_subst(src/lexer/skip.rs) — tokenizer span; drives-cstatus.skip_parenthesized_unit_corrected(src/lexer/skip.rs) — oracle behindcommand_substitutions_balanced; drives the REPL verdict.skip_parenthesized_unit_corrected_ex(src/lexer/continuation.rs) — staged mirror used bycomsub_residuals_advanceandclose_char_residuals_advance.The close arm is guarded by
opener_depth_before == 0, so a pending pattern-list opener still owns its)— the gate's pinned holds on(),(a|),(|),a(b|)and(a|() echo hi;; esac)are preserved.has_unclosed_command_substitutionitself is untouched (its false positives are still overridden viacommand_substitutions_balanced, as before).Verification (Simular box, base
8100d76):tests/issue3307_repl_unclosed_case_comsub.rs: 4/4 pass; fail-first confirmed — the two released-family tests fail on the base tree.has_unclosed_input_syntax_posixnow equals the gate on all 44 probed shapes.-c:a|anda|went 2 (EOF) → 127 (GNU: 127); controls unchanged.echo $(case x in a|)now errors immediately instead of PS2.cargo test --lib: 1249 passed, 0 failed, 4 ignored.rustfmt --check,git diff --check,cargo check --tests,RUSTFLAGS="-D warnings"lib+bins build, marker-lint and utf8-boundary scripts all clean.Known residuals (out of scope, pre-existing):
echo $(echo $(case x in a|)): the gate itself holds it (its case machine is global across the nested substitution), so the feeder holds too; GNU gives 127. Gate-vs-GNU divergence, not gate-vs-feeder.echo $(case x in a|) $(echo ok):-cprints the syntax error but still runs the rest (rc 0) — the parser extractor's region never arms for separator-tail shapes (deferred in Release unclosed-case bodies at the completeness gate (stacked on the read-time validation change) #3303's notes).(),(a|), …): the gate holds them and the fix preserves the hold, while GNU errors immediately — the pinned gate-test boundary.