Repository navigation
syntax: materialize grouped alternation in pattern contexts - #800
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f094d7b01
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
6f094d7 to
ffe01bb
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ffe01bb5b3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
8bf3d73 to
39f3b54
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39f3b543fd
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e7f907bba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| group, end, ok := r.parsePatternGroup(raw, base, i) | ||
| if end > i { | ||
| if ok { | ||
| flushLit(partStart, i) | ||
| parts = append(parts, group) |
There was a problem hiding this comment.
Restrict PatternGroup parsing in extglob arm literals
parseParts now materializes any parenthesized alternation as PatternGroup, even when parsing an extglob arm. In bash/ksh pattern syntax, parentheses inside extglob arms are literal unless introduced by an extglob operator, so inputs like [[ "(a|b)" == @(x|(a|b)) ]] (and equivalent case patterns) are valid. After this change, the (a|b) arm is turned into PatternGroup, and the new bare-group validation in followCondPattern/caseItems rejects it as an unexpected ( in non-zsh variants, causing valid scripts to fail parsing.
Useful? React with 👍 / 👎.
Summary
PatternGroupAST node for bare grouped alternation in pattern contexts[[ == ]]/[[ = ]]/[[ != ]]andcasepatterns, with recovery that preserves enclosing AST nodes(failures and update printer, fidelity, typedjson, expand, docs, and testsRoot cause
Grouped alternation in pattern contexts was being treated as token-level syntax noise instead of a structured pattern construct. That prevented gbash from materializing the surrounding
TestClause,CaseClause, andIfClausein recovery cases and forced downstream consumers to fall back to raw line scans.Impact
This gives analyzers a real AST node for zsh grouped alternation and a typed, recoverable failure shape for bash-like parses. It removes the need for line-scan fallbacks in the affected pattern checks and keeps surrounding syntax trees available under
RecoverErrors.Validation
go test ./shell/syntaxgo test ./shell/syntax/typedjsongo test ./shell/expand