From: Robert Griesemer Date: Mon, 14 Jan 2013 23:25:42 +0000 (-0800) Subject: go/types: set type of lhs ident in type switch guards X-Git-Tag: go1.1rc2~1388 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0822a62cb76e347a4ac2a8731e7d24b4c894f79f;p=gostls13.git go/types: set type of lhs ident in type switch guards (bug fix) R=adonovan CC=golang-dev https://golang.org/cl/7098059 --- diff --git a/src/pkg/go/types/stmt.go b/src/pkg/go/types/stmt.go index f1d6704110..11a2e7196d 100644 --- a/src/pkg/go/types/stmt.go +++ b/src/pkg/go/types/stmt.go @@ -610,10 +610,10 @@ func (check *checker) stmt(s ast.Stmt) { } // There is only one object (lhs) associated with a lhs identifier, but that object - // assumes different types for different clauses. Set it to nil when we are done so - // that the type cannot be used by mistake. + // assumes different types for different clauses. Set it back to the type of the + // TypeSwitchGuard expression so that that variable always has a valid type. if lhs != nil { - lhs.Type = nil + lhs.Type = x.typ } case *ast.SelectStmt: