]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: set type of lhs ident in type switch guards
authorRobert Griesemer <gri@golang.org>
Mon, 14 Jan 2013 23:25:42 +0000 (15:25 -0800)
committerRobert Griesemer <gri@golang.org>
Mon, 14 Jan 2013 23:25:42 +0000 (15:25 -0800)
(bug fix)

R=adonovan
CC=golang-dev
https://golang.org/cl/7098059

src/pkg/go/types/stmt.go

index f1d6704110574bf6ff142627819ae6fdc87d59bd..11a2e7196dc5dae73aaeb8f2c0a540161e44f972 100644 (file)
@@ -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: