Open findleyr opened 1 year ago
@mdempsky in this case I think there is a bug in the unified reader (in the compiler only): specifically here: https://cs.opensource.google/go/go/+/master:src/cmd/compile/internal/importer/ureader.go;l=510;drc=6cf6067d4eb20dfb3d31c0a8ccdbfdf0bf304b72
In this case, SetConstraint is called during the set-up of the parent named type, but (for better or worse) is documented that it should be called only after "the bound's underlying is fully defined". https://pkg.go.dev/cmd/compile/internal/types2#TypeParam.SetConstraint
The go/types unified importer calls SetConstraint in a later: https://cs.opensource.google/go/go/+/master:src/go/internal/gcimporter/ureader.go;l=618;drc=0cd309e12818f988693bf8e4d9f1453331dcf9f2
Can we do the same in the compiler? The obvious alternative is to make the bound calculation lazy, and that is liable to have a larger blast radius than pushing additional complexity into the importer.
CC @griesemer as well.
Tentatively marked this for 1.22, as I think this bug has existed for a long time; if the fix proves to be safe, perhaps we can back-port.
This didn't make 1.23, unfortunately. Moving to 1.24.
As mentioned in https://github.com/golang/go/issues/60817#issuecomment-1728279951_:
Output:
Here is a Playground where you can reproduce the problem.
Originally posted by @jub0bs in https://github.com/golang/go/issues/60817#issuecomment-1728279951