From: Robert Griesemer Date: Thu, 25 Aug 2022 21:30:15 +0000 (-0700) Subject: go/types: avoid declared but not used error for a couple of cases X-Git-Tag: go1.20rc1~1405 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=27006657fad10d195dd0f5d5719e49a4e5811f4a;p=gostls13.git 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 TryBot-Result: Gopher Robot Run-TryBot: Robert Griesemer Auto-Submit: Robert Griesemer Reviewed-by: Alan Donovan --- diff --git a/src/go/types/testdata/check/builtins0.go b/src/go/types/testdata/check/builtins0.go index 936595b06b..f4932a8309 100644 --- a/src/go/types/testdata/check/builtins0.go +++ b/src/go/types/testdata/check/builtins0.go @@ -482,7 +482,7 @@ func make1() { } func make2() { - f1 /* ERROR not used */ := func() (x []int) { return } + f1 := func() (x []int) { return } _ = make(f0 /* ERROR not a type */ ()) _ = make(f1 /* ERROR not a type */ ()) } @@ -502,7 +502,7 @@ func new1() { } func new2() { - f1 /* ERROR not used */ := func() (x []int) { return } + f1 := func() (x []int) { return } _ = new(f0 /* ERROR not a type */ ()) _ = new(f1 /* ERROR not a type */ ()) } diff --git a/src/go/types/typexpr.go b/src/go/types/typexpr.go index 397bd75db3..13adb9f2a9 100644 --- a/src/go/types/typexpr.go +++ b/src/go/types/typexpr.go @@ -377,6 +377,7 @@ func (check *Checker) typInternal(e0 ast.Expr, def *Named) (T Type) { default: check.errorf(e0, _NotAType, "%s is not a type", e0) + check.use(e0) } typ := Typ[Invalid]