aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vet/main.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2018-09-12 18:07:51 -0700
committerRobert Griesemer <gri@golang.org>2018-09-13 15:25:25 +0000
commit77e503a3224ada21cc84ab9078980a7d4230492a (patch)
tree133c64a18f1c19cf2c70792330f49d6340cc5c5a /src/cmd/vet/main.go
parent8149db4f64aa72407d8be2184d0b414b535cd124 (diff)
downloadgo-77e503a3224ada21cc84ab9078980a7d4230492a.tar.gz
go-77e503a3224ada21cc84ab9078980a7d4230492a.zip
cmd/vet: avoid internal error for implicitly declared type switch vars
For type switches using a short variable declaration of the form switch t := x.(type) { case T1: ... go/types doesn't declare the symbolic variable (t in this example) with the switch; thus such variables are not found in types.Info.Defs. Instead they are implicitly declared with each type switch case, and can be found in types.Info.Implicits. Adjust the shadowing code accordingly. Added a test case to verify that the issue is fixed, and a test case verifying that the shadowing code now considers implicitly declared variables introduces in type switch cases. While at it, also fixed the (internal) error reporting to provide more accurate information. Fixe #26725. Change-Id: If408ed9e692bf47c640f81de8f46bf5eb43415b0 Reviewed-on: https://go-review.googlesource.com/135117 Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src/cmd/vet/main.go')
-rw-r--r--src/cmd/vet/main.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/cmd/vet/main.go b/src/cmd/vet/main.go
index c50d4885a0..646adf4d76 100644
--- a/src/cmd/vet/main.go
+++ b/src/cmd/vet/main.go
@@ -467,6 +467,7 @@ type Package struct {
path string
defs map[*ast.Ident]types.Object
uses map[*ast.Ident]types.Object
+ implicits map[ast.Node]types.Object
selectors map[*ast.SelectorExpr]*types.Selection
types map[ast.Expr]types.TypeAndValue
spans map[types.Object]Span