Repository navigation
preserve heredoc closer metadata - #791
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 574806384a
ℹ️ 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".
eae2073 to
b0040d0
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0040d0b56
ℹ️ 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".
| if s = p.gotStmtPipe(s, false); s == nil { | ||
| return nil | ||
| } | ||
| if p.err != nil && !stmtHasHeredocMetadata(s) { |
There was a problem hiding this comment.
Stop parsing after returning a heredoc-error statement
The new guard in getStmt keeps going when p.err is set if stmtHasHeredocMetadata(s) is true, but stmts only stops when getStmt returns nil; this means a fatal heredoc-related parse error can still be followed by parsing and appending later statements from the same input. For inputs where a heredoc body triggers an error and additional script text follows, callers get a misleading AST that includes statements after the first unrecoverable error.
Useful? React with 👍 / 👎.
Summary
Preserve here-doc closer metadata on
shell/syntax.HeredocDelimso the AST keeps the final close-site instead of only the normalized opener metadata and body text.What Changed
HeredocDelim, including close positions, raw close text, match state, EOF termination, trailing text, and<<-indent resultsPos()/End()behavior or printer outputSPEC.mdWhy
The parser already matches heredoc close lines during lexing, but the AST discarded that information after body parsing. This left an upstream metadata hole for tooling that needs to inspect the actual close site, especially for unmatched or near-match heredocs.
Impact
External
shell/syntaxconsumers can now inspect the physical heredoc closer candidate directly, including EOF termination and tab-stripping details for<<-, without changing printer behavior or redirect span semantics.Validation
go test ./shell/syntax ./shell/syntax/typedjsonmake lint