Skip to content

Commit

Permalink
gopls/internal/golang: downgrade bug.Reportf for missing builtin
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
adonovan committed Feb 2, 2024
1 parent 9c43803 commit e80085c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gopls/internal/golang/definition.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ func builtinDecl(ctx context.Context, snapshot *cache.Snapshot, obj types.Object
astObj := file.Scope.Lookup(name)
if astObj == nil {
// Every built-in should have documentation syntax.
return nil, bug.Errorf("internal error: no object for %s", name)
// However, it is possible to reach this statement by
// commenting out declarations in {builtin,unsafe}.go.
return nil, fmt.Errorf("internal error: no object for %s", name)
}
decl, ok := astObj.Decl.(ast.Node)
if !ok {
Expand Down

0 comments on commit e80085c

Please sign in to comment.