From 6c12918c7da09244c48002dd295cd0f757f6f82a Mon Sep 17 00:00:00 2001 From: "prath.shenoy" Date: Sun, 17 May 2026 18:07:55 +0000 Subject: [PATCH] fix: Quit panicking on named types over error --- internal/lookup/lookup.go | 8 +--- .../snapshots/input/pr258/consumer.go | 11 +++++ .../snapshots/input/pr258/deplib/errors.go | 3 ++ .../snapshots/input/pr258/deplib/go.mod | 3 ++ .../testdata/snapshots/input/pr258/go.mod | 7 +++ .../snapshots/output/pr258/consumer.go | 46 +++++++++++++++++++ 6 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 internal/testdata/snapshots/input/pr258/consumer.go create mode 100644 internal/testdata/snapshots/input/pr258/deplib/errors.go create mode 100644 internal/testdata/snapshots/input/pr258/deplib/go.mod create mode 100644 internal/testdata/snapshots/input/pr258/go.mod create mode 100755 internal/testdata/snapshots/output/pr258/consumer.go diff --git a/internal/lookup/lookup.go b/internal/lookup/lookup.go index 51c9b68..27b9c7c 100644 --- a/internal/lookup/lookup.go +++ b/internal/lookup/lookup.go @@ -151,13 +151,7 @@ func (p *Global) GetSymbolOfObject(obj types.Object) (*scip.SymbolInformation, b case *types.Builtin: return nil, false, nil case *types.Func: - if orig := obj.Origin(); orig != nil { - name := orig.FullName() - switch name { - case "(error).Error": - return nil, false, nil - } - } + return nil, false, nil } panic(fmt.Sprintf("failed to create symbol for builtin obj: %T %+v | %s", obj, obj, obj.Id())) diff --git a/internal/testdata/snapshots/input/pr258/consumer.go b/internal/testdata/snapshots/input/pr258/consumer.go new file mode 100644 index 0000000..ce0256e --- /dev/null +++ b/internal/testdata/snapshots/input/pr258/consumer.go @@ -0,0 +1,11 @@ +package consumer + +import "github.com/example/deplib" + +var Sentinel deplib.CustomErr + +func New() deplib.CustomErr { return nil } + +type Wrapper struct { + Err deplib.CustomErr +} diff --git a/internal/testdata/snapshots/input/pr258/deplib/errors.go b/internal/testdata/snapshots/input/pr258/deplib/errors.go new file mode 100644 index 0000000..7424151 --- /dev/null +++ b/internal/testdata/snapshots/input/pr258/deplib/errors.go @@ -0,0 +1,3 @@ +package deplib + +type CustomErr error diff --git a/internal/testdata/snapshots/input/pr258/deplib/go.mod b/internal/testdata/snapshots/input/pr258/deplib/go.mod new file mode 100644 index 0000000..ceea55a --- /dev/null +++ b/internal/testdata/snapshots/input/pr258/deplib/go.mod @@ -0,0 +1,3 @@ +module github.com/example/deplib + +go 1.22 diff --git a/internal/testdata/snapshots/input/pr258/go.mod b/internal/testdata/snapshots/input/pr258/go.mod new file mode 100644 index 0000000..5f7961e --- /dev/null +++ b/internal/testdata/snapshots/input/pr258/go.mod @@ -0,0 +1,7 @@ +module sg/pr258 + +go 1.22 + +require github.com/example/deplib v0.0.0 + +replace github.com/example/deplib => ./deplib diff --git a/internal/testdata/snapshots/output/pr258/consumer.go b/internal/testdata/snapshots/output/pr258/consumer.go new file mode 100755 index 0000000..c59e14a --- /dev/null +++ b/internal/testdata/snapshots/output/pr258/consumer.go @@ -0,0 +1,46 @@ + package consumer +// ^^^^^^^^ definition 0.1.test `sg/pr258`/ +// kind Package +// display_name consumer +// signature_documentation +// > package consumer + + import "github.com/example/deplib" +// ^^^^^^^^^^^^^^^^^^^^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/ + + var Sentinel deplib.CustomErr +// ^^^^^^^^ definition 0.1.test `sg/pr258`/Sentinel. +// kind Variable +// display_name Sentinel +// signature_documentation +// > var Sentinel deplib.CustomErr +// ^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/ +// ^^^^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/CustomErr# + +//⌄ enclosing_range_start 0.1.test `sg/pr258`/New(). + func New() deplib.CustomErr { return nil } +// ^^^ definition 0.1.test `sg/pr258`/New(). +// kind Function +// display_name New +// signature_documentation +// > func New() deplib.CustomErr +// ^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/ +// ^^^^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/CustomErr# +// ⌃ enclosing_range_end 0.1.test `sg/pr258`/New(). + + type Wrapper struct { +// ^^^^^^^ definition 0.1.test `sg/pr258`/Wrapper# +// kind Struct +// display_name Wrapper +// signature_documentation +// > type Wrapper struct{ Err deplib.CustomErr } + Err deplib.CustomErr +// ^^^ definition 0.1.test `sg/pr258`/Wrapper#Err. +// kind Field +// display_name Err +// signature_documentation +// > struct field Err deplib.CustomErr +// ^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/ +// ^^^^^^^^^ reference github.com/example/deplib 0.1.test `github.com/example/deplib`/CustomErr# + } +