Skip to content

Don't add global diags when not checking a file#4257

Open
jakebailey wants to merge 2 commits into
mainfrom
jabaile/no-global-diags-when-not-checking
Open

Don't add global diags when not checking a file#4257
jakebailey wants to merge 2 commits into
mainfrom
jabaile/no-global-diags-when-not-checking

Conversation

@jakebailey

Copy link
Copy Markdown
Member

Perf optimization; if we aren't checking a file, we don't want the global diags. Don't bother saving them. They can only be spurious.

Copilot AI review requested due to automatic review settings June 10, 2026 02:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines diagnostic collection in the Go checker to avoid retaining “global” (no-file) diagnostics outside the active file-checking path, with the goal of reducing overhead and preventing spurious global diagnostics from being saved.

Changes:

  • Introduces checkingSourceFile state in the checker to gate deferred diagnostic callback capture.
  • Updates addDiagnostic to early-return at max serialization depth and to skip global diagnostics unless a source file is actively being checked.
  • Cleans up the serialization-level guard logic in addDiagnostic to use an early return.

Comment thread internal/checker/checker.go Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants