Skip to content

Commit e80085c

Browse files
committed
gopls/internal/golang: downgrade bug.Reportf for missing builtin
I am able to reproduce the bug by commenting out declarations in builtin.go or unsafe.go, which is very unlikely to happen in practice but reason enough not to call bug.Reportf. Fixes golang/go#64604 Change-Id: Idc7e0b2bda0b6070f3d09ba9cb825b7f28b8f796 Reviewed-on: https://go-review.googlesource.com/c/tools/+/560897 Reviewed-by: Robert Findley <rfindley@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent 9c43803 commit e80085c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

gopls/internal/golang/definition.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ func builtinDecl(ctx context.Context, snapshot *cache.Snapshot, obj types.Object
118118
astObj := file.Scope.Lookup(name)
119119
if astObj == nil {
120120
// Every built-in should have documentation syntax.
121-
return nil, bug.Errorf("internal error: no object for %s", name)
121+
// However, it is possible to reach this statement by
122+
// commenting out declarations in {builtin,unsafe}.go.
123+
return nil, fmt.Errorf("internal error: no object for %s", name)
122124
}
123125
decl, ok := astObj.Decl.(ast.Node)
124126
if !ok {

0 commit comments

Comments
 (0)