Skip to content

fix(go): return nil instead of panic when AST node has invalid position#197

Merged
wzekin merged 2 commits into
cloudwego:mainfrom
wzekin:fix/recover-from-invalid-ast-position
Jun 1, 2026
Merged

fix(go): return nil instead of panic when AST node has invalid position#197
wzekin merged 2 commits into
cloudwego:mainfrom
wzekin:fix/recover-from-invalid-ast-position

Conversation

@wzekin
Copy link
Copy Markdown
Collaborator

@wzekin wzekin commented Jun 1, 2026

When parsing files with compilation errors, AST nodes can have End offset smaller than Pos offset, causing slice bounds out of range panic.

What type of PR is this?

Check the PR title.

  • This PR title match the format: <type>(optional scope): <description>
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Attach the PR updating the user documentation if the current PR requires user awareness at the usage level. User docs repo

(Optional) Translate the PR title into Chinese.

(Optional) More detailed description for this PR(en: English/zh: Chinese).

en:
zh(optional):

(Optional) Which issue(s) this PR fixes:

(optional) The PR that updates user documentation:

When parsing files with compilation errors, AST nodes can have End offset
smaller than Pos offset, causing slice bounds out of range panic.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wzekin wzekin force-pushed the fix/recover-from-invalid-ast-position branch from 0bc6331 to 3668ead Compare June 1, 2026 07:33
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@wzekin wzekin force-pushed the fix/recover-from-invalid-ast-position branch from 3668ead to 6df9391 Compare June 1, 2026 07:43
@wzekin wzekin merged commit ca1eba0 into cloudwego:main Jun 1, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants