fix: suppress type errors after syntax errors - #2266
Conversation
There was a problem hiding this comment.
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
gopackagesalias is justified — the existinginternal/packagesalias re-exportsError/Packagetypes but not theParseError/TypeErrorkind constants. (Optionally, re-exporting those two constants frominternal/packageswould let this file keep a singlepackagesidentifier.)
| }) | ||
| if len(errs) > 0 { | ||
| for _, errPkg := range errs { | ||
| hasParseError := false |
There was a problem hiding this comment.
Two small maintainability points on this block:
- The first loop can collapse into a single pass —
slicesis already imported, sohasParseError := slices.ContainsFunc(errPkg.Errors, func(e packages.Error) bool { return e.Kind == gopackages.ParseError })avoids iteratingerrPkg.Errorstwice. - Silently dropping
TypeErroroutput when aParseErroris 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
No main baseline exists yet; all metrics are marked Warning
|
No description provided.