aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Peppe <rogpeppe@gmail.com>2011-03-30 09:45:51 -0700
committerRobert Griesemer <gri@golang.org>2011-03-30 09:45:51 -0700
commitdba96cf411bc06cc3d75be160d420fc457b4a598 (patch)
treeb920b5ca2c308f2b033b5c1bb47aabe163981b2d
parent6b567d26b74e7b98c540a9779a798cd95334dc87 (diff)
downloadgo-dba96cf411bc06cc3d75be160d420fc457b4a598.tar.gz
go-dba96cf411bc06cc3d75be160d420fc457b4a598.zip
go/parser: fix scoping for local type declarations
R=gri CC=golang-dev https://golang.org/cl/4332045
-rw-r--r--src/pkg/go/parser/parser.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/pkg/go/parser/parser.go b/src/pkg/go/parser/parser.go
index ad7e4cdcf2..5b1edace1b 100644
--- a/src/pkg/go/parser/parser.go
+++ b/src/pkg/go/parser/parser.go
@@ -2016,16 +2016,17 @@ func parseTypeSpec(p *parser, doc *ast.CommentGroup, _ int) ast.Spec {
}
ident := p.parseIdent()
- typ := p.parseType()
- p.expectSemi() // call before accessing p.linecomment
// Go spec: The scope of a type identifier declared inside a function begins
// at the identifier in the TypeSpec and ends at the end of the innermost
// containing block.
// (Global identifiers are resolved in a separate phase after parsing.)
- spec := &ast.TypeSpec{doc, ident, typ, p.lineComment}
+ spec := &ast.TypeSpec{doc, ident, nil, p.lineComment}
p.declare(spec, p.topScope, ast.Typ, ident)
+ spec.Type = p.parseType()
+ p.expectSemi() // call before accessing p.linecomment
+
return spec
}