mirror of https://github.com/golang/go.git
go/types, types2: don't panic converting a constant to aliased type parameter
For #67547. Change-Id: I1b2118a311dce906327ae6e29e582da539c60b2b Reviewed-on: https://go-review.googlesource.com/c/go/+/587157 Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
816b6031fe
commit
814e72f2ef
|
|
@ -56,7 +56,7 @@ func (check *Checker) conversion(x *operand, T Type) {
|
|||
// If T's type set is empty, or if it doesn't
|
||||
// have specific types, constant x cannot be
|
||||
// converted.
|
||||
ok = T.(*TypeParam).underIs(func(u Type) bool {
|
||||
ok = Unalias(T).(*TypeParam).underIs(func(u Type) bool {
|
||||
// u is nil if there are no specific type terms
|
||||
if u == nil {
|
||||
cause = check.sprintf("%s does not contain specific types", T)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ func (check *Checker) conversion(x *operand, T Type) {
|
|||
// If T's type set is empty, or if it doesn't
|
||||
// have specific types, constant x cannot be
|
||||
// converted.
|
||||
ok = T.(*TypeParam).underIs(func(u Type) bool {
|
||||
ok = Unalias(T).(*TypeParam).underIs(func(u Type) bool {
|
||||
// u is nil if there are no specific type terms
|
||||
if u == nil {
|
||||
cause = check.sprintf("%s does not contain specific types", T)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
// Copyright 2024 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 p
|
||||
|
||||
func _[P int]() {
|
||||
type A = P
|
||||
_ = A(0) // don't crash with this conversion
|
||||
}
|
||||
Loading…
Reference in New Issue