1
0
mirror of https://github.com/golang/go synced 2024-11-18 17:04:41 -07:00

go.tools/go/types: record lhs identifier in switch lhs := rhs.(type)

Added testcase.

R=adonovan
CC=golang-dev
https://golang.org/cl/11742043
This commit is contained in:
Robert Griesemer 2013-07-24 12:38:51 -07:00
parent d4f2f2d7fa
commit d0657ebb0d
2 changed files with 7 additions and 1 deletions

View File

@ -45,7 +45,12 @@ var sources = []string{
func (_ T) m() {}
var i I
var _ = i.m
func _(s []int) { for i, x := range s {} }
func _(s []int) { for i, x := range s {} }
func _(x interface{}) {
switch x := x.(type) {
case int:
}
}
`,
}

View File

@ -356,6 +356,7 @@ func (check *checker) stmt(s ast.Stmt) {
check.invalidAST(s.Pos(), "incorrect form of type switch guard")
return
}
check.recordObject(lhs, nil) // lhs is implicitly declared in each cause clause
rhs = guard.Rhs[0]