You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: internal error when instantiating constrained generic type parameter #81627
package main
import (
"cmp"
"fmt"
)
func main() {
Fns := []func(x, y int) bool{cmp.Less}
fmt.Printf("%v", Fns[0](1, 2))
}
What did you see happen?
The compiler reports this internal error
./prog.go:9:34: internal compiler error: func[T cmp.Ordered](x T, y T) bool is not assignable to func(x int, y int) bool
Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
Go build failed.
What did you expect to see?
Successful compilation, or a non-internal error, depending on how Go instantiates constrained generic type parameters
changed the title [-]compiler: internal error when instantiating constrained generic type parameter[/-][+]cmd/compile: internal error when instantiating constrained generic type parameter[/+]on Sep 21, 2026
This seems to reproduce on tip. A bisect landed on f757de8:
first BAD: f757de83f4 | 2026-04-21 03:14 | go/types, types2: improve type inference for assignment contexts
GOOD parent: 3304e73ded | 2026-04-20 23:56 | Revert "net/http/internal/http2: prevent alloc when writing status code for responses"
Activity
[-]compiler: internal error when instantiating constrained generic type parameter[/-][+]cmd/compile: internal error when instantiating constrained generic type parameter[/+]gabyhelp commentedon Sep 21, 2026
Related Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
thepudds commentedon Sep 21, 2026
This seems to reproduce on tip. A bisect landed on f757de8:
CC @griesemer @mrkfrmn
griesemer commentedon Sep 21, 2026
Hm. Looks like something goes awry in the UIR (superficial inspection) as this program typechecks ok outside the compiler.
There's of course the obvious work-around which is to instantiate explicitly (playground):
cc: @mrkfrmn
gopherbot commentedon Sep 30, 2026
Change https://go.dev/cl/841725 mentions this issue:
cmd/compile: handle inferred generic function values in UIR