Skip to content

Conversation

@jakebailey
Copy link
Member

@jakebailey jakebailey commented Dec 3, 2025

Now that we do not need to ask multiple checkers for their errors anymore, we can restructure the funcs to make a bit more sense.

I've tried to simplify things. Notably:

  • Were asking for binding way too often. We only need to do it before creating a checker (we need this during startup for globals/ambients), and then for GetBindDiagnostics which is is "special" and is used solely for timing tsc.
  • We sometimes combine bind diags with semantic diags, so we could have the same diag objects when deduping. I've added fast paths to the diag comparison methods.
  • ForEachCheckerParallel is now limited to non-Project Programs, used for stats/testing.

Copilot AI review requested due to automatic review settings December 3, 2025 19:44
@jakebailey jakebailey changed the title Clarify Program diagnostic API Make Program diagnostic API clearer Dec 3, 2025
Copilot finished reviewing on behalf of jakebailey December 3, 2025 19:48
Copy link
Contributor

Copilot AI left a comment

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 refactors the Program diagnostic API to simplify diagnostic collection and improve performance. The main changes eliminate redundant binding operations that occurred at multiple levels, now that the system uses a single checker pool instead of multiple checkers.

Key Changes:

  • Introduced a new collectDiagnostics helper function that centralizes the pattern of collecting diagnostics from one or all files
  • Removed the complex getDiagnosticsHelper function in favor of simpler, more direct implementations
  • Added pointer equality fast paths to diagnostic comparison functions to optimize deduplication when bind and semantic diagnostics share the same objects
  • Renamed GetSemanticDiagnosticsNoFilter to GetSemanticDiagnosticsForFiles for clarity

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/ast/diagnostic.go Added pointer equality fast paths in EqualDiagnostics, EqualDiagnosticsNoRelatedInfo, equalMessageChain, and CompareDiagnostics to optimize deduplication performance
internal/compiler/program.go Major refactoring: introduced collectDiagnostics helper, simplified all diagnostic collection methods, removed redundant binding calls, renamed GetSemanticDiagnosticsNoFilter to GetSemanticDiagnosticsForFiles, and replaced slices.Concat with core.Concatenate
internal/execute/incremental/program.go Updated call from GetSemanticDiagnosticsNoFilter to GetSemanticDiagnosticsForFiles to match the renamed function

@jakebailey jakebailey enabled auto-merge December 3, 2025 21:20
@jakebailey jakebailey added this pull request to the merge queue Dec 3, 2025
Merged via the queue into main with commit c86b860 Dec 3, 2025
22 checks passed
@jakebailey jakebailey deleted the jabaile/clearer-diag-api branch December 3, 2025 21:46
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.

3 participants