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:
parent
d4f2f2d7fa
commit
d0657ebb0d
@ -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:
|
||||
}
|
||||
}
|
||||
`,
|
||||
}
|
||||
|
||||
|
@ -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]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user