diff options
Diffstat (limited to 'src/cmd/compile/internal/noder')
| -rw-r--r-- | src/cmd/compile/internal/noder/stmt.go | 3 | ||||
| -rw-r--r-- | src/cmd/compile/internal/noder/types.go | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/noder/stmt.go b/src/cmd/compile/internal/noder/stmt.go index 1e996b95c4..a349a7ef10 100644 --- a/src/cmd/compile/internal/noder/stmt.go +++ b/src/cmd/compile/internal/noder/stmt.go @@ -13,8 +13,10 @@ import ( "cmd/internal/src" ) +// stmts creates nodes for a slice of statements that form a scope. func (g *irgen) stmts(stmts []syntax.Stmt) []ir.Node { var nodes []ir.Node + types.Markdcl() for _, stmt := range stmts { switch s := g.stmt(stmt).(type) { case nil: // EmptyStmt @@ -24,6 +26,7 @@ func (g *irgen) stmts(stmts []syntax.Stmt) []ir.Node { nodes = append(nodes, s) } } + types.Popdcl() return nodes } diff --git a/src/cmd/compile/internal/noder/types.go b/src/cmd/compile/internal/noder/types.go index 4f6d828720..ed816b4955 100644 --- a/src/cmd/compile/internal/noder/types.go +++ b/src/cmd/compile/internal/noder/types.go @@ -123,7 +123,14 @@ func (g *irgen) typ0(typ types2.Type) *types.Type { // Make sure the base generic type exists in type1 (it may // not yet if we are referecing an imported generic type, as // opposed to a generic type declared in this package). - _ = g.obj(typ.Origin().Obj()) + base := g.obj(typ.Origin().Obj()) + if base.Class == ir.PAUTO { + // If the base type is a local type, we want to pop + // this instantiated type symbol/definition when we + // leave the containing block, so we don't use it + // incorrectly later. + types.Pushdcl(s) + } // Create a forwarding type first and put it in the g.typs // map, in order to deal with recursive generic types |
