Skip to content

Commit

Permalink
go/types, types2: don't panic converting a constant to aliased type p…
Browse files Browse the repository at this point in the history
…arameter

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>
  • Loading branch information
griesemer authored and gopherbot committed May 21, 2024
1 parent 816b603 commit 814e72f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types2/conversions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/go/types/conversions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/internal/types/testdata/fixedbugs/issue67547.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 814e72f

Please sign in to comment.