1
0
mirror of https://github.com/golang/go synced 2024-11-17 02:24:42 -07:00

go/types: avoid declared but not used error for a couple of cases

The change in typexpr.go matches types2 behavior.

For #54511.

Change-Id: I79c922a94f2ee0440c1814140935c321439c7d25
Reviewed-on: https://go-review.googlesource.com/c/go/+/425714
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Griesemer 2022-08-25 14:30:15 -07:00 committed by Gopher Robot
parent aab8d2b448
commit 27006657fa
2 changed files with 3 additions and 2 deletions

View File

@ -482,7 +482,7 @@ func make1() {
} }
func make2() { func make2() {
f1 /* ERROR not used */ := func() (x []int) { return } f1 := func() (x []int) { return }
_ = make(f0 /* ERROR not a type */ ()) _ = make(f0 /* ERROR not a type */ ())
_ = make(f1 /* ERROR not a type */ ()) _ = make(f1 /* ERROR not a type */ ())
} }
@ -502,7 +502,7 @@ func new1() {
} }
func new2() { func new2() {
f1 /* ERROR not used */ := func() (x []int) { return } f1 := func() (x []int) { return }
_ = new(f0 /* ERROR not a type */ ()) _ = new(f0 /* ERROR not a type */ ())
_ = new(f1 /* ERROR not a type */ ()) _ = new(f1 /* ERROR not a type */ ())
} }

View File

@ -377,6 +377,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) {
default: default:
check.errorf(e0, _NotAType, "%s is not a type", e0) check.errorf(e0, _NotAType, "%s is not a type", e0)
check.use(e0)
} }
typ := Typ[Invalid] typ := Typ[Invalid]