]> Cypherpunks.ru repositories - gostls13.git/commitdiff
go/types: avoid declared but not used error for a couple of cases
authorRobert Griesemer <gri@golang.org>
Thu, 25 Aug 2022 21:30:15 +0000 (14:30 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 26 Aug 2022 03:34:24 +0000 (03:34 +0000)
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>
src/go/types/testdata/check/builtins0.go
src/go/types/typexpr.go

index 936595b06baa03c3d59ddabefa36d39da4e36832..f4932a8309eef7807c12197f3f5c4eebb6870b21 100644 (file)
@@ -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 */ ())
 }
index 397bd75db336f3448188e3697f29b1037f632311..13adb9f2a982dd25ed80891289feca35cf1d19eb 100644 (file)
@@ -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]