diff --git a/go/types/resolver_test.go b/go/types/resolver_test.go index bb1ed9131c4..99bf62ec471 100644 --- a/go/types/resolver_test.go +++ b/go/types/resolver_test.go @@ -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: + } + } `, } diff --git a/go/types/stmt.go b/go/types/stmt.go index a55bb5bdaca..dd35dfc8cdd 100644 --- a/go/types/stmt.go +++ b/go/types/stmt.go @@ -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]