]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: include AST in instantiatedIdent panic message
authorAlan Donovan <adonovan@google.com>
Tue, 28 Nov 2023 21:07:01 +0000 (16:07 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 28 Nov 2023 22:55:47 +0000 (22:55 +0000)
Updates golang/go#63933

Change-Id: I3ff71e92d124c850eb8b4d136e163bf5786897a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/545615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

src/go/types/check.go

index 4a5f0731df956387e4516e21d111059fe64fac10..85fd0744d234f293f1884d45fbce35b9ec2b5123 100644 (file)
@@ -14,6 +14,7 @@ import (
        "go/token"
        "internal/godebug"
        . "internal/types/errors"
+       "strings"
 )
 
 // nopos indicates an unknown position
@@ -618,7 +619,12 @@ func instantiatedIdent(expr ast.Expr) *ast.Ident {
        case *ast.SelectorExpr:
                return x.Sel
        }
-       panic("instantiated ident not found")
+
+       // extra debugging of #63933
+       var buf strings.Builder
+       buf.WriteString("instantiated ident not found; please report: ")
+       ast.Fprint(&buf, token.NewFileSet(), expr, ast.NotNilFilter)
+       panic(buf.String())
 }
 
 func (check *Checker) recordDef(id *ast.Ident, obj Object) {