Repository navigation
adds typed metadata to shell/syntax.ParseError - #790
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3824cec38d
ℹ️ 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".
| case ParseErrorKindUnmatched: | ||
| return len(err.Expected) == 1 && err.Expected[0] == ParseErrorSymbolRightBrace && err.Construct == ParseErrorSymbolLeftBrace |
There was a problem hiding this comment.
Treat EOF unmatched
{ as recoverable in backquotes
parseErrRecoverableInBackquotes now only treats brace mismatches as recoverable when Kind == ParseErrorKindUnmatched, but matchingErr classifies the same {/} mismatch as ParseErrorKindUnclosed whenever the unexpected token is EOF (via missingCloseKind). That means EOF-terminated brace mismatches in backquote parsing no longer enter the recovery path (recoverBackquoteCmdSubst), so malformed backquotes that were previously recoverable can now abort parsing instead of letting outer script parsing continue.
Useful? React with 👍 / 👎.
Summary
This change adds typed metadata to
shell/syntax.ParseErrorso callers can inspect parse failures without scraping diagnostic text.What changed
ParseErrorKindandParseErrorSymboltypes and exposeKind,Construct,Unexpected,Expected, andIsRecoverableonParseErrorText,Error(),BashError(), andRecoverable()behavior while keeping compound recovery on recovered positions and existing clause token slotsParseError.Textstring matchingParseErrormetadata surface inSPEC.mdWhy
The parser already recovers compound-command structure through recovered positions and existing node fields, but
ParseErroronly exposed stringly diagnostics. This left downstream consumers parsingTextto decide whether an error was missing, unexpected, unclosed, recoverable, or tied to a specific shell construct. The new metadata makes that API stable without changing the AST recovery model.Validation
make lintgo test ./shell/syntaxgo test ./shell/expandgo test ./internal/shell ./internal/shell/interpgo test ./...except for the existing oracle-backed failures ininternal/builtinswhenGBASH_CONFORMANCE_RIPGREPandGBASH_CONFORMANCE_DIFFare not set in the environment