-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go/types: 'under' panics on Alias type #68877
Comments
Many thanks for the very helpful bug report. The input program that reproduces the problem can be reduced to the following, which does not use cgo: package main
type (
T struct{}
U = T
S U
) Loading it using this reduced main program: package main
import (
"go/types"
"log"
"golang.org/x/tools/go/packages"
)
func main() {
cfg := &packages.Config{Mode: packages.NeedTypes}
pkgs, err := packages.Load(cfg, ".")
if err != nil {
log.Fatal(err)
}
obj := pkgs[0].Types.Scope().Lookup("S").(*types.TypeName)
_ = obj.String() // panics
} produces the same crash:
|
Reducing again to eliminate packages.Load: func TestIssue68877(t *testing.T) {
setGotypesalias(t, true)
const src = `package main
type (
T struct{}
U = T
S U
)`
pkg := mustTypecheck(src, nil, nil)
S := pkg.Scope().Lookup("S").(*TypeName)
_ = S.String()
} |
cc: @timothy-king for visibility |
Analysis so far: The underlying problem (no pun intended) is that The endless seem to be caused by invalid code (alias cycles). Should have a tentative CL later today. |
Change https://go.dev/cl/605757 mentions this issue: |
Gopherbot, please create a backport issue for Go 1.23. |
We need ‘@‘ the bot. |
@gopherbot, please create a backport issue for Go 1.23: this is a regression in the type checker when run with |
Backport issue(s) opened: #68894 (for 1.23). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/605977 mentions this issue: |
Go version
go version go1.23.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
Minimal example: https://github.com/varungandhi-src/underpanic
I had some code using using APIs like
String
on*types.Named
, as well as functions liketypes.NewMethodSet
.I upgraded that from Go 1.22.4 to Go 1.23.0
What did you see happen?
What did you expect to see?
Functions like
NewMethodSet
and methods likeString
should continue to work in the presence of CGo.The text was updated successfully, but these errors were encountered: