• Robert Griesemer's avatar
    cmd/vet: avoid internal error for implicitly declared type switch vars · 77e503a3
    Robert Griesemer authored
    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: 's avatarDaniel Martí <mvdan@mvdan.cc>
    Reviewed-by: 's avatarAlan Donovan <adonovan@google.com>
    77e503a3
Name
Last commit
Last update
..
addr2line Loading commit data...
api Loading commit data...
asm Loading commit data...
buildid Loading commit data...
cgo Loading commit data...
compile Loading commit data...
cover Loading commit data...
dist Loading commit data...
doc Loading commit data...
fix Loading commit data...
go Loading commit data...
gofmt Loading commit data...
internal Loading commit data...
link Loading commit data...
nm Loading commit data...
objdump Loading commit data...
pack Loading commit data...
pprof Loading commit data...
test2json Loading commit data...
trace Loading commit data...
vendor Loading commit data...
vet Loading commit data...