]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] cmd/compile: more informative panic when importing generic...
authorRobert Griesemer <gri@golang.org>
Wed, 24 Jul 2024 22:01:07 +0000 (15:01 -0700)
committerRobert Griesemer <gri@google.com>
Fri, 26 Jul 2024 03:55:54 +0000 (03:55 +0000)
commit3509415eca0eac695c706eaf63cb4c8d8d69b7f2
treec414a6bf360581ec8c67d6d8f1981c476ff48f2e
parent559c77592f182a2f77f2d70328cb649609517bd3
[release-branch.go1.23] cmd/compile: more informative panic when importing generic type alias

When GOEXPERIMENT=aliastypeparams is set, type aliases may have type
parameters. The compiler export data doesn't export that type parameter
information yet, which leads to an index-out-of-bounds panic when a
client package imports a package with a general type alias and then
refers to one of the missing type parameters.

This CL detects this specific case and panics with a more informative
panic message explaining the shortcoming. The change is only in effect
if the respective GOEXPERIMENT is enabled.

Manually tested. No test addded since this is just a temporary fix
(Go 1.24 will have a complete implementation), and because the existing
testing framework doesn't easily support testing that a compilation
panics.

Together with @taking and input from @rfindley.

For #68526.

Change-Id: I24737b153a7e2f9b705cd29a5b70b2b9e808dffc
Reviewed-on: https://go-review.googlesource.com/c/go/+/601035
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/importer/ureader.go