Repository navigation
fix(parser): token-level errors preempt compound EOF reports (#3405) - #3423
Conversation
GNU report_syntax_error (parse.y:6833) exits at a concrete token
(parse.y:6852-6865, current_token != 0 with EOF_Reached == 0) before
the EOF branch (parse.y:6890-6901) can report an open compound, so
inside an unclosed compound the first token-level verdict in the
region precedes every "unexpected end of file from `X'" report.
The brace and paren EOF arms consulted only the mismatched closer,
and the keyword arm neither candidate, so a dangling redirection
inside an unclosed compound (`X() { (a)>`, `while true; do >`) was
reported as the compound's EOF error instead of GNU's
`syntax error near unexpected token `newline'' at the operator's
line. The brace/paren arms now order both candidates by offending
token position (preempting_token_error_node over
dangling_redirect_in_region, the scan the first W-DIAG residual
wave left unwired), and the keyword arm consults the dangling scan
(foreign closers keep their caller-side routing there).
Refs #3405
GNU bash 5.3.20 expectations for the probe matrix (lane dossier probes.py E-series): the fail-first cells are the dangling-redirect shapes inside unclosed compounds and command substitutions; the controls are the clean-EOF shapes (clean comsub body, unclosed if, complete brace group, top-level dangling redirect, the continuation exception, the backquote counter-shape, the pending heredoc). Refs #3405
|
复核判词:FAIL——头编不过。首代 CI 9 腿全 fail(34s–1m50s)+ niubash 腿 fail,日志原文逐腿核对过,全部是同一对编译错,不是 flake:
两处都在本次 PR 的新代码里;其余腿(回归钉双边、三方探针、lib、fmt、 另有一件返工须交代:issue 要求四形全钉,钉文件 19 个测试里没有 shape 4(`case x in `` 反向形)——请说明 shape 4 是否已重验、决定不钉的依据(附 GNU 实测),或补钉。 返工后请通知重审;当前头不得合入。 |
…port (#3405, part B) GNU parses a command substitution body with a nested yyparse (parse.y:4549-4555), so a token-level error inside the body - a redirect operator whose target word never arrives, a bare ( after body text - fails that parse BEFORE the matched-pair EOF is reached, and report_syntax_error (parse.y:6833-6865) names the offending token with the matching suffix. rubash classified only the bare-( shape for eval strings and the file route never consulted the classifier at all, so x=$( ( a) >> reported the plain matching-EOF at the past-end line in file mode and in eval strings alike. - lexer/skip.rs: unclosed_comsub_eof_shape learns the dangling- redirect class (comsub_body_dangling_redirect: first redirect operator at the innermost unclosed comsub body's own depth whose next meaningful character is a newline or the end of input), returned as ComsubBodyTokenError, preempting both the invalid- paren class when it sits earlier in the text and the ComsubEof tail. The eval/trap consumers already render that shape with the FORCE_EOF abort, so the eval face (eval 'x=$( ( a) >>' now exits 1 with no continuation) is fixed by the classification alone. - script_driver.rs: the file-mode unclosed route's comsub arm now consults the classifier and emits the near-token report (suffix + offending line, exit 2) ahead of the plain matching-EOF. - executor/public_accessors.rs: report_comsub_body_parse_error applies GNU's suffix rule (parse.y:6858-6859) - a missing-target error whose operator is the body's last token died on the comsub's own )' (the sub-parse EOF token, parse.y:4519), so it names )' WITHOUT the suffix; an operator followed by a physical newline inside the body keeps newline' with the suffix (x=$( ( a) >> ) case). Also carries two small signature refinements in the part-A helpers left uncommitted in the lane tree (opener: &'static str, Rc<str> deref at the case call site). Refs #3405
|
Captain re-review — FAIL (dossier: review-3423/CAPTAIN-VERIFY.md §5; first-round FAIL was the uncompilable head, comment 6822595909) The two compile errors are fixed and the head now compiles ( Failing pins (head output vs GNU)
What already stands (no rework needed there)
Rework path: fix only the two reds above, push a new head, wait for CI all green, and notify the captain for a focused re-review (pin stem 19/19 + three-way probe table + lib name sets; intersection recomputed against the then-live tip). |
…ken errors reach file mode (#3405, part C) Round-2 rework for the two remaining reds in PR #3423 (re-review FAIL, CAPTAIN-VERIFY.md §5.4): 1. `( (a)>` named the pure subshell EOF form. `parse_subshell_command` returns None and the fallback `push_unclosed_paren_error` only knew the two #413 pre-EOF events, while the dangling-redirect arm lived only in `unclosed_paren_eof_node` (function-definition `()`). The left-to-right scan now also consults `dangling_redirect_in_region` and returns whichever event — dangling redirect, #413 (a)/(b) — its token position reaches first ("first offender wins", parse.y:6833). 2. `x=$(echo (` reported the matched-pair EOF in file mode although the eval face already named `newline` with the matching suffix. Root cause is routing, not classification: the close-char scan reports the bare `(` inside the comsub body as a command-position paren, the real parser stays silent (the lexer swallows the body into the word token), so `command_paren_verdict_disproved_by_parser` disproved the unclosed route and execution fell through to the comsub-expansion EOF report. The disproof no longer fires when `unclosed_comsub_eof_shape` yields a ComsubBodyTokenError (parse.y:4549-4555 nested yyparse owns the diagnostic), and the command-position branch of the unclosed route defers to the ComsubBody arm instead of its subshell-EOF fallthrough. The shape's own guards (#516/q1, `((` arithmetic root, `for ((` pair) keep those families out of the class, so their reports are unchanged. Same family, token naming: `token_after_paren` returned an empty token when an operator followed the invalid `(` (`x=$(echo (>` named ``). Operators now lex maximal-munch per GNU read_token (parse.y:3630-3800); spellings byte-verified against GNU bash 5.3.20. GNU anchors: parse.y:532, 6833, 6858-6859, 4549-4555, 6890-6901.
|
【WIN-AGENT-AUDIT】 机制核查:
腿(逐项给数字与名字):
F 点:无 续作记录:无(本轮只审不改) 未跑/VOID 的腿:
|
|
【WIN-AGENT-BATCH-SUMMARY】 Wave 2 后半 11 个 PR 审核完毕(win-agent, worktree D:/repo/rubash-devin-w6)。各 PR 报告已发至各自评论区,判词均为建议。
阻塞项汇总:
process 卫生:本 turn 结束自查(见下)。 |
What
Inside an unclosed compound at end of input, GNU's parser dies on the
first token-level error in the region (report_syntax_error,
parse.y:6833/6852-6865) and only reports the compound's
"unexpected end of file" form when the parse survives to exhaustion
(parse.y:6890-6901). rubash's compound EOF arms always preferred the
outer EOF report, so a dangling redirection inside an unclosed
compound was misreported:
eval 'X() { (a)>'— GNU:eval: line 1: syntax error near unexpected token \newline'; rubash: the unclosed-{` EOF form.x=$( ( a) >>— GNU:syntax error near unexpected token \newline' while looking for matching `)'`; rubash: the plainmatching-EOF form.
This change orders the verdicts by construct state, not by shape:
the brace/paren EOF arms order the mismatched-closer and
dangling-redirection candidates by offending-token position, and
the keyword EOF arm consults the dangling-redirection scan.
Deletions
None — the change is additive in
parse_loopplus call-sitesignature threading in the keyword EOF arm.
Fixes #3405
Part B (comsub bodies)
A command substitution body is a nested yyparse (parse.y:4549-4555),
so a token-level error inside the body — a redirect operator whose
target never arrives, a bare
(after body text — preempts thematched-pair EOF report there too:
lexer/skip.rs:unclosed_comsub_eof_shapelearns thedangling-redirect class (first redirect operator at the innermost
unclosed comsub body's own depth whose next meaningful character is
a newline or end of input), returned as
ComsubBodyTokenErrorandordered against the invalid-paren class by text position. The
eval/trap consumers already render that shape with the FORCE_EOF
abort, so
eval 'x=$( ( a) >>'now exits 1 with no continuation.script_driver.rs: the file-mode unclosed route's comsub armconsults the classifier and emits the near-token report ahead of
the plain matching-EOF.
executor/public_accessors.rs:report_comsub_body_parse_errorapplies GNU's suffix rule (parse.y:6858-6859) — an operator that is
the body's last token died on the comsub's own
)and names itwithout the suffix (
x=$( ( a) >> )); an operator followed by aphysical newline inside the body keeps `newline' with the suffix.
Verification legs (box, per-stem) are reported on the issue thread as
they land.