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:
parent
d4f2f2d7fa
commit
d0657ebb0d
|
|
@ -46,6 +46,11 @@ var sources = []string{
|
||||||
var i I
|
var i I
|
||||||
var _ = i.m
|
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:
|
||||||
|
}
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -356,6 +356,7 @@ func (check *checker) stmt(s ast.Stmt) {
|
||||||
check.invalidAST(s.Pos(), "incorrect form of type switch guard")
|
check.invalidAST(s.Pos(), "incorrect form of type switch guard")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
check.recordObject(lhs, nil) // lhs is implicitly declared in each cause clause
|
||||||
|
|
||||||
rhs = guard.Rhs[0]
|
rhs = guard.Rhs[0]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue