Skip to content

Commit 814e72f

Browse files
griesemergopherbot
authored andcommitted
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 <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 816b603 commit 814e72f

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/cmd/compile/internal/types2/conversions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func (check *Checker) conversion(x *operand, T Type) {
5656
// If T's type set is empty, or if it doesn't
5757
// have specific types, constant x cannot be
5858
// converted.
59-
ok = T.(*TypeParam).underIs(func(u Type) bool {
59+
ok = Unalias(T).(*TypeParam).underIs(func(u Type) bool {
6060
// u is nil if there are no specific type terms
6161
if u == nil {
6262
cause = check.sprintf("%s does not contain specific types", T)

src/go/types/conversions.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2024 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package p
6+
7+
func _[P int]() {
8+
type A = P
9+
_ = A(0) // don't crash with this conversion
10+
}

0 commit comments

Comments
 (0)