Repository navigation
fix(lexer): unquoted digit-leading compound LHS is a GNU parse-time syntax error (Refs #3495) - #3862
Merged
Merged
Conversation
…yntax error (Refs #3495) GNU anchors: parse.y:5653 (compound branch gated on token_is_assignment) -> parse.y:5270 token_is_assignment -> general.c:480 assignment() with the legal_variable_starter gate (general.c:498-502); parse.y:1054 function-head '(' shift names the next token for a bare '9bad=(x)'. - lexer/word.rs: compound_assignment_start now requires an ASCII-letter/'_' first character, matching classification::is_assignment and token_actions::valid_compound_assignment_lhs (both already enforced it since #3464). '9bad=(x)' no longer folds into one word: the word ends at '9bad=' and the parser's stray-'(' arm reports 'syntax error near unexpected token `('`', rc 2, whole script dies. - test: the #3464 nail that locked the InvalidId interim now expects the parse error; new tests/issue3495_digit_compound_parse_error.rs nails the class (declare/typeset/export/readonly/local, '+=', subscript, bare, echo-arg, eval containment) and the guards (quoted, paren-less scalar, valid names still bind). UNVERIFIED-BY-CAPTAIN
caomengxuan666
marked this pull request as ready for review
November 17, 2026 16:21
Member
Author
|
#3862 判词=PASS merge=59d1c2b4e lexer首字符门对齐GNU assignment(),20/20钉绿+GNU逐字节一致 head: 928cb4a(审计基座 9f909d6 + 本 lane rustfmt 提交 928cb4a,仅换行)base(merge-base): 3d8c9ff 文件: 3 个 +361/-7→合并后净 +354/-7 机制核查:
腿:
F 点:无。 续作记录:
未跑/VOID 的腿:无。 备注:PR 正文称钉 "21 tests",实为 20 个 #[test](已合入,不改判)。 |
Member
Author
|
【k2 批次汇总】本波分工:#3862 审计 + #3835 接手核查
阻塞项:无。 |
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.
Refs #3495 (follow-up of the PR #3464 review, Refs #3186).
Root cause
declare -a 9bad=(x): GNU is a parse-time syntax error (syntax error near unexpected token '(', rc=2, whole script dies); rubash reported a builtin diagnostic (declare: '9bad=(x)': not a valid identifier, rc=1, script continues).GNU gates the
=(compound branch ontoken_is_assignment(parse.y:5653 -> parse.y:5270 -> general.c:480assignment()), which requires a legal-variable-starter first character (general.c:498-502). The lexer'scompound_assignment_start(src/lexer/word.rs) used a weaker all-alnum-plus-any-alpha test, so it folded9bad=(x)into one atomic word and the declare builtin saw it as a flat operand. The two sibling validators —classification::is_assignmentandtoken_actions::valid_compound_assignment_lhs— already enforced the starter rule since #3464; the lexer fold was the only decision point that did not.Fix
One predicate in
compound_assignment_start: require the first byte to be an ASCII letter or_. The word now ends at9bad=, the(reaches the parser as a stray token, and the existing stray-(arm reports the GNU error (rc 2, whole script dies). No parser or builtin change was needed.Nail disposition
The #3464 nail
declare_a_digit_leading_compound_unquoted_is_invalid_idexplicitly locked the InvalidId interim (rc=1). It is updated in place (renamed to..._is_parse_error) to expect the parse-time error, and the file header records the resolution. New stemtests/issue3495_digit_compound_parse_error.rs(21 tests) nails the class — declare/typeset/export/readonly/local,+=, subscript, bare9bad=(x)(namesx, parse.y:1054 function-head shift), echo argument,if-wrapped, eval containment — plus the guards that must not change: quoted'9bad=(x)'and paren-less9bad=xstay InvalidId (rc=1), valida9=/_9=compounds still bind.本 PR 删除了什么
Nothing. No code, test, file, or behaviour is removed; the #3464 nail is retargeted (same test, new expectation), not deleted.
Verification (honest status)
ssh -p 2666→ Connection refused; only the user can relaunch it on the PC). Simular box dead (wallet empty). Local build banned (no toolchain on this VM, MemAvailable ~0.5G). New-server hop 1 was restored this round (VM replacement had wiped/root/.ssh/; config + known_hosts recreated, host key fingerprint re-verified against the recorded SHA256). Old-server direct route needs the box-held key and is not usable from here.cargo fmt --checknot run (no toolchain on this VM); the pre-commit hook skips cleanly in that case. Formatting follows the surrounding style; re-check on the build machine.compound_assignment_starthas exactly one caller (skip_word_inner); impact set is the word scanner only.UNVERIFIED-BY-CAPTAIN