mirror of
https://github.com/golang/go
synced 2024-11-25 06:47:56 -07:00
go/parser: fix scoping for local type declarations
R=gri CC=golang-dev https://golang.org/cl/4332045
This commit is contained in:
parent
6b567d26b7
commit
dba96cf411
@ -2016,16 +2016,17 @@ func parseTypeSpec(p *parser, doc *ast.CommentGroup, _ int) ast.Spec {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ident := p.parseIdent()
|
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
|
// 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
|
// at the identifier in the TypeSpec and ends at the end of the innermost
|
||||||
// containing block.
|
// containing block.
|
||||||
// (Global identifiers are resolved in a separate phase after parsing.)
|
// (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)
|
p.declare(spec, p.topScope, ast.Typ, ident)
|
||||||
|
|
||||||
|
spec.Type = p.parseType()
|
||||||
|
p.expectSemi() // call before accessing p.linecomment
|
||||||
|
|
||||||
return spec
|
return spec
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user