mirror of
https://github.com/golang/go
synced 2024-11-25 19:27:56 -07:00
cmd/compile/internal/types2: add a check for nil reason in assignableTo
A recent change to error message formatting was missing a nil check. Fixes #49592 Change-Id: Ic1843e0277ba75eec0e8e41fe34b59c323d7ea31 Reviewed-on: https://go-review.googlesource.com/c/go/+/364034 Trust: Robert Findley <rfindley@google.com> Trust: Dan Scales <danscales@google.com> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
b6342a02ad
commit
92655582d0
@ -316,7 +316,9 @@ func (x *operand) assignableTo(check *Checker, T Type, reason *string) (bool, er
|
||||
// not an interface.
|
||||
if check != nil && check.conf.CompilerErrorMessages {
|
||||
if isInterfacePtr(Tu) {
|
||||
*reason = check.sprintf("%s does not implement %s (%s is pointer to interface, not interface)", x.typ, T, T)
|
||||
if reason != nil {
|
||||
*reason = check.sprintf("%s does not implement %s (%s is pointer to interface, not interface)", x.typ, T, T)
|
||||
}
|
||||
return false, _InvalidIfaceAssign
|
||||
}
|
||||
if Vi, _ := Vu.(*Interface); Vi != nil && Vp == nil {
|
||||
|
11
src/cmd/compile/internal/types2/testdata/fixedbugs/issue49592.go2
vendored
Normal file
11
src/cmd/compile/internal/types2/testdata/fixedbugs/issue49592.go2
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2021 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 _() {
|
||||
var x *interface{}
|
||||
var y interface{}
|
||||
_ = x == y
|
||||
}
|
11
src/go/types/testdata/fixedbugs/issue49592.go2
vendored
Normal file
11
src/go/types/testdata/fixedbugs/issue49592.go2
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2021 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 _() {
|
||||
var x *interface{}
|
||||
var y interface{}
|
||||
_ = x == y
|
||||
}
|
13
test/fixedbugs/issue49592.go
Normal file
13
test/fixedbugs/issue49592.go
Normal file
@ -0,0 +1,13 @@
|
||||
// compile
|
||||
|
||||
// Copyright 2021 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 _() {
|
||||
var x *interface{}
|
||||
var y interface{}
|
||||
_ = x == y
|
||||
}
|
Loading…
Reference in New Issue
Block a user