aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/api/api_test.go
diff options
context:
space:
mode:
authorDevon H. O'Dell <dhobsd@google.com>2024-01-04 11:49:17 -0500
committerGopher Robot <gobot@golang.org>2024-01-04 17:31:12 +0000
commit15dcdeb5aacb4503e3d053f198bd4669d5cec2aa (patch)
tree2d10f68540a4ef6f4d017ae57993adfebc1f14d0 /src/cmd/api/api_test.go
parent6db1102605f227093ea95538f0fe9e46022ad7ea (diff)
downloadgo-15dcdeb5aacb4503e3d053f198bd4669d5cec2aa.tar.xz
cmd/api: fix panic on exported basic type aliases
The order of emitting named type and type aliases in the `Walker`'s `emitType` function is inverted. When the type alias references a basic type, this causes a panic as the type assertion on `*types.Named` fails. This change reorders the logic such that type aliases are emitted prior to this type assertion. Fixes #64958 Change-Id: I52dbe13999978912ded788d9cf4948103869bcfa Reviewed-on: https://go-review.googlesource.com/c/go/+/554076 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/cmd/api/api_test.go')
-rw-r--r--src/cmd/api/api_test.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cmd/api/api_test.go b/src/cmd/api/api_test.go
index 910e046f12..ba358d364d 100644
--- a/src/cmd/api/api_test.go
+++ b/src/cmd/api/api_test.go
@@ -285,6 +285,25 @@ func TestIssue41358(t *testing.T) {
}
}
+func TestIssue64958(t *testing.T) {
+ defer func() {
+ if x := recover(); x != nil {
+ t.Errorf("expected no panic; recovered %v", x)
+ }
+ }()
+
+ testenv.MustHaveGoBuild(t)
+
+ for _, context := range contexts {
+ w := NewWalker(context, "testdata/src/issue64958")
+ pkg, err := w.importFrom("p", "", 0)
+ if err != nil {
+ t.Errorf("expected no error importing; got %T", err)
+ }
+ w.export(pkg)
+ }
+}
+
func TestCheck(t *testing.T) {
if !*flagCheck {
t.Skip("-check not specified")