mirror of
https://github.com/golang/go
synced 2024-11-26 07:27:59 -07:00
go/parser: remove redundant list argument to Parser.shortVarDecl
Change-Id: I75d089a7c1c3cdd50e5d2dafdb3386620efff4c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/304454 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
152ca79b73
commit
1d8abb3417
@ -137,12 +137,12 @@ func (p *parser) declare(decl, data interface{}, scope *ast.Scope, kind ast.ObjK
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *parser) shortVarDecl(decl *ast.AssignStmt, list []ast.Expr) {
|
func (p *parser) shortVarDecl(decl *ast.AssignStmt) {
|
||||||
// Go spec: A short variable declaration may redeclare variables
|
// Go spec: A short variable declaration may redeclare variables
|
||||||
// provided they were originally declared in the same block with
|
// provided they were originally declared in the same block with
|
||||||
// the same type, and at least one of the non-blank variables is new.
|
// the same type, and at least one of the non-blank variables is new.
|
||||||
n := 0 // number of new variables
|
n := 0 // number of new variables
|
||||||
for _, x := range list {
|
for _, x := range decl.Lhs {
|
||||||
if ident, isIdent := x.(*ast.Ident); isIdent {
|
if ident, isIdent := x.(*ast.Ident); isIdent {
|
||||||
assert(ident.Obj == nil, "identifier already declared or resolved")
|
assert(ident.Obj == nil, "identifier already declared or resolved")
|
||||||
obj := ast.NewObj(ast.Var, ident.Name)
|
obj := ast.NewObj(ast.Var, ident.Name)
|
||||||
@ -161,7 +161,7 @@ func (p *parser) shortVarDecl(decl *ast.AssignStmt, list []ast.Expr) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if n == 0 && p.mode&DeclarationErrors != 0 {
|
if n == 0 && p.mode&DeclarationErrors != 0 {
|
||||||
p.error(list[0].Pos(), "no new variables on left side of :=")
|
p.error(decl.Lhs[0].Pos(), "no new variables on left side of :=")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1987,7 +1987,7 @@ func (p *parser) parseSimpleStmt(mode int) (ast.Stmt, bool) {
|
|||||||
}
|
}
|
||||||
as := &ast.AssignStmt{Lhs: x, TokPos: pos, Tok: tok, Rhs: y}
|
as := &ast.AssignStmt{Lhs: x, TokPos: pos, Tok: tok, Rhs: y}
|
||||||
if tok == token.DEFINE {
|
if tok == token.DEFINE {
|
||||||
p.shortVarDecl(as, x)
|
p.shortVarDecl(as)
|
||||||
}
|
}
|
||||||
return as, isRange
|
return as, isRange
|
||||||
}
|
}
|
||||||
@ -2382,7 +2382,7 @@ func (p *parser) parseCommClause() *ast.CommClause {
|
|||||||
rhs := p.parseRhs()
|
rhs := p.parseRhs()
|
||||||
as := &ast.AssignStmt{Lhs: lhs, TokPos: pos, Tok: tok, Rhs: []ast.Expr{rhs}}
|
as := &ast.AssignStmt{Lhs: lhs, TokPos: pos, Tok: tok, Rhs: []ast.Expr{rhs}}
|
||||||
if tok == token.DEFINE {
|
if tok == token.DEFINE {
|
||||||
p.shortVarDecl(as, lhs)
|
p.shortVarDecl(as)
|
||||||
}
|
}
|
||||||
comm = as
|
comm = as
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user