diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index 632adc7f93..5693d5ffd4 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -1818,7 +1818,7 @@ func isTermNode(n ir.Node) bool { } func Conv(n ir.Node, t *types.Type) ir.Node { - if types.Identical(n.Type(), t) { + if types.IdenticalStrict(n.Type(), t) { return n } n = ir.NewConvExpr(base.Pos, ir.OCONV, nil, n) @@ -1830,7 +1830,7 @@ func Conv(n ir.Node, t *types.Type) ir.Node { // ConvNop converts node n to type t using the OCONVNOP op // and typechecks the result with ctxExpr. func ConvNop(n ir.Node, t *types.Type) ir.Node { - if types.Identical(n.Type(), t) { + if types.IdenticalStrict(n.Type(), t) { return n } n = ir.NewConvExpr(base.Pos, ir.OCONVNOP, nil, n) diff --git a/test/typeparam/issue54537.go b/test/typeparam/issue54537.go new file mode 100644 index 0000000000..614ed4648d --- /dev/null +++ b/test/typeparam/issue54537.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2022 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func main() { + _ = F[bool] + + var x string + _ = G(x == "foo") +} + +func F[T ~bool](x string) { + var _ T = x == "foo" +} + +func G[T any](t T) *T { + return &t +}