Skip to content

fix: suppress type errors after syntax errors - #2266

Open
MeteorsLiu wants to merge 2 commits into
xgo-dev:mainfrom
MeteorsLiu:fix/goroot-bug388-diagnostics
Open

fix: suppress type errors after syntax errors#2266
MeteorsLiu wants to merge 2 commits into
xgo-dev:mainfrom
MeteorsLiu:fix/goroot-bug388-diagnostics

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Contributor

No description provided.

@fennoai fennoai Bot 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.

Review: suppress type errors after syntax errors

Focused, correct change. Verified that the diagnostic suppression cannot cause a failed build to appear successful: buildSSAPkgs returns fmt.Errorf("cannot build SSA for packages") whenever len(errs) > 0, and package pass/fail is driven by IllTyped (set in internal/packages/load.go whenever len(lpkg.Errors) > 0), independent of which diagnostics are printed. Suppression is correctly scoped per-package (hasParseError is reset each errPkg iteration), and a pure type-error package still prints its diagnostics. No security or performance concerns (this runs only on the error path).

Two maintainability suggestions inline. Nothing blocking.

  • The added gopackages alias is justified — the existing internal/packages alias re-exports Error/Package types but not the ParseError/TypeError kind constants. (Optionally, re-exporting those two constants from internal/packages would let this file keep a single packages identifier.)

Comment thread internal/build/build.go
})
if len(errs) > 0 {
for _, errPkg := range errs {
hasParseError := false

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.

Two small maintainability points on this block:

  1. The first loop can collapse into a single pass — slices is already imported, so hasParseError := slices.ContainsFunc(errPkg.Errors, func(e packages.Error) bool { return e.Kind == gopackages.ParseError }) avoids iterating errPkg.Errors twice.
  2. Silently dropping TypeError output when a ParseError is present is a deliberate decision (type errors are cascading noise once a file fails to parse). A one-line comment explaining the rationale would prevent a future reader from mistaking it for accidental error swallowing.

@codecov

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

LLGo baseline benchmarks

5446982c9887 | workflow run | long-term charts

Program measurements

Platform Workload File size vs main Build vs main Run vs main
Linux cprintf 18544 B new 339.196 ms new 1.359 ms new
Linux fmtprintf 2217608 B new 3.269 s new 2.460 ms new
Linux println 71504 B new 343.895 ms new 1.569 ms new
macOS cprintf 84672 B new 351.507 ms new 2.568 ms new
macOS fmtprintf 2361520 B new 3.366 s new 19.744 ms new
macOS println 125712 B new 335.133 ms new 3.906 ms new
Core language and compiler benchmarks
Platform Benchmark ns/op vs main
Linux BenchmarkLookupPCRandom 13.220 ns/op new
Linux BenchmarkMergeCompilerFlags 152 ns/op new
Linux BenchmarkMergeLinkerFlags 93.960 ns/op new
Linux BenchmarkChannelBuffered 33.960 ns/op new
Linux BenchmarkChannelHandoff 26731 ns/op new
Linux BenchmarkDefer 42.080 ns/op new
Linux BenchmarkDirectCall 1.573 ns/op new
Linux BenchmarkGlobalRead 1.868 ns/op new
Linux BenchmarkGlobalWrite 2.485 ns/op new
Linux BenchmarkGoroutine 31247 ns/op new
Linux BenchmarkInterfaceCall 8.104 ns/op new
Linux BenchmarkRuntimeGetG 1.867 ns/op new
macOS BenchmarkLookupPCRandom 11.960 ns/op new
macOS BenchmarkMergeCompilerFlags 155.100 ns/op new
macOS BenchmarkMergeLinkerFlags 84.020 ns/op new
macOS BenchmarkChannelBuffered 23.920 ns/op new
macOS BenchmarkChannelHandoff 7889 ns/op new
macOS BenchmarkDefer 28.040 ns/op new
macOS BenchmarkDirectCall 1.078 ns/op new
macOS BenchmarkGlobalRead 1.058 ns/op new
macOS BenchmarkGlobalWrite 1.020 ns/op new
macOS BenchmarkGoroutine 49058 ns/op new
macOS BenchmarkInterfaceCall 5.056 ns/op new
macOS BenchmarkRuntimeGetG 2.046 ns/op new

No main baseline exists yet; all metrics are marked new.

Warning

  • The rendered benchmark data could not be pushed.

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.

1 participant