Repository navigation
fix(parser): report first offending reserved word in case-in-comsub syntax errors (Refs #3628) - #3901
Merged
Merged
Conversation
…rs (#3628) `case' inside a command substitution (and plain case clause bodies) reported the wrong unexpected token: GNU names the token that actually arrived where the grammar expected something else, but rubash blamed a later `esac'/`;;'/`)'/EOF. Two cooperating defects: - src/parser/token_actions.rs: the command-position reserved-word rejection (command_is_pending_pipeline_prefix) omitted `in', so a bare `in' at command position became a command word instead of the token yyerror names. GNU parse.y CHECK_FOR_RESERVED_WORD (parse.y:3168-3187) and the compound_list grammar (parse.y:1262) admit no production for it; `in' is the only member of reserved_word_acceptable's complement (parse.y:5899-5937) that is not itself a boundary predecessor. Argument/command-name position is preserved: `x=1 in a' and `>f in a' still run `in' -> `in: command not found' (rc 127), and `echo in' / `echo done' stay legal. - src/parser/case_command.rs case_body_end: a lexical `done|fi|then|else|elif` break stopped the clause-body walk at those keywords without reporting them, swallowing the real offender so a later token was blamed (and misfiring on argument-position same-spellings like `echo done fi'). Removed the break so the real body parser judges command position, and added command-position offender detection (flat && at_command_start && structural_keyword) that reports the FIRST can't-start-command keyword like GNU's yyerror (parse.y:6724/6833/6850-6865) — fixing `in esac' (whose `esac' the boundary scan cannot see) and first-offender-beats-stray-`)'. Regression coverage in tests/issue3628_case_in_comsub_token.rs (12 tests): the comsub reproducer (`v=$(case x in x) done ;; esac)' -> `done' while looking for matching `)', `in' likewise, `esac ;;' -> `;;'), the shared clause-body root cause, `in' command-position rejection, and argument-position preservation. Verified against WSL GNU Bash 5.3.20 (script-file probes): every probed case-body/comsub keyword now names the same token with the same rc. Known pre-existing limitation (unchanged): the NEAR-channel source echo for a case nested inside while/if echoes the clause span, not the full physical line — same as the existing stray-`)`/`|' offenders. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
队长复核 PASS 并合入(钉期望对齐,无产品代码变更,chore 类豁免删除节)。 头 CI 裁定:census 78,issue3833 茎 8 PASS / 0 FAIL(对齐生效),与现尖 census 逐名零新增;goldens 基线二名;CLI 全绿。fail-first 即现尖 census 的原红格(旧期望在 #3901 后的产品上必红);期望本身由 GNU 5.3.20 oracle 实测背书(`! in` / 裸 `in` / `| in` 皆 rc 2)。
This was referenced Nov 18, 2026
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.
Fixes #3628. Adds in to command-position reserved-word rejection and replaces case_body_end silent break with first-offender detection matching GNU parse.y.