Skip to content

feat: VerboseError + click-jumpable error format - #11

Merged
crhntr merged 3 commits into
mainfrom
bump/tools-to-v0.44.0
May 7, 2026
Merged

feat: VerboseError + click-jumpable error format#11
crhntr merged 3 commits into
mainfrom
bump/tools-to-v0.44.0

Conversation

@crhntr

@crhntr crhntr commented May 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds VerboseError (a new error interface) plus CallError and IdentifierError carrying *types.Signature / types.Type so consumers can render multi-line diagnostics that include the full function signature, the navigated type, and — for named types — the original Go source declaration with its godoc.
  • Reformats template type errors so the line begins with file:line:col: (click-jumpable in terminals/IDEs); the rest of the line keeps the same shape text/template produces at runtime.
  • Prefixes the not-found message with field or method for clarity.
  • Drive-by fixes uncovered while refactoring: checkCallArguments was returning the parameter type instead of the function's result on the pointer-deref fallback; builtInCheck had copy-pasted built-in eq… messages, an off-by-one in slice arg-count, and panicked on empty argTypes for len/slice/index.

The cmd/check-templates CLI now prints via check.FormatVerbose(err), which walks errors.Join trees and prefers each leaf's verbose form.

Test plan

  • go test ./...
  • go vet ./...
  • staticcheck ./...
  • gofmt -l .
  • Updated EqualError/ErrorContains and scripttest patterns to match the new format.
  • Added error_verbose_test.go and error_verbose_internal_test.go covering the new error types, Unwrap, fallback behavior, joined-error walking, and the source-rendering helper (with and without godoc).

Copilot AI review requested due to automatic review settings May 6, 2026 16:34
crhntr added 3 commits May 6, 2026 22:17
Introduce CallError and IdentifierError carrying types.Signature and
types.Type so consumers can render multi-line diagnostics that include
the full function signature, the navigated type, and — for named types —
the original source declaration with its godoc. Existing Error() output
is preserved; the new path activates via FormatVerbose, which the CLI
now uses.

Also:
- unify *Error formatting so newError and wrapError both produce the
  location prefix (previously only newError did)
- fix checkCallArguments returning the parameter type instead of the
  function's result on the pointer-deref fallback
- fix copy-paste "built-in eq..." messages on and/or and comparison
  builtins, off-by-one in slice arg-count message, and panics on empty
  argTypes for len/slice/index

Assisted-by: Claude:claude-opus-4-7 gopls staticcheck
…line:col

Errors now begin directly with the location, matching the convention
gopls and the Go compiler use. Terminals and IDEs treat the leading
file:line:col as a clickable jump-to-source target. The remainder of
the line keeps the same shape produced by text/template at runtime
(executing %q at <ctx>: msg), which also simplifies the runtime-error
comparison helper in check_test.go.

Updated affected EqualError/ErrorContains/Output assertions and
scripttest patterns.

Assisted-by: Claude:claude-opus-4-7 gopls staticcheck
Templates only ever look up fields or methods through .Foo chains, so
making that explicit in the error message clarifies what the resolver
was attempting and matches Go's own diagnostic phrasing.

Assisted-by: Claude:claude-opus-4-7 gopls staticcheck
@crhntr
crhntr force-pushed the bump/tools-to-v0.44.0 branch from adbf64f to 9040db5 Compare May 7, 2026 05:23
@crhntr
crhntr merged commit 79f3c2a into main May 7, 2026
1 check passed
@crhntr
crhntr deleted the bump/tools-to-v0.44.0 branch May 7, 2026 08:57
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