mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/syntax: generalize error about var decls in init clauses
Change-Id: I62f9748b97bec245338ebf9686fbf6ad6dc6a9c2 Reviewed-on: https://go-review.googlesource.com/36931 Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
f823d30514
commit
efb3cab960
3 changed files with 17 additions and 13 deletions
|
|
@ -1703,8 +1703,8 @@ func (p *parser) header(keyword token) (init SimpleStmt, cond Expr, post SimpleS
|
|||
|
||||
if p.tok != _Semi {
|
||||
// accept potential varDecl but complain
|
||||
if keyword == _For && p.got(_Var) {
|
||||
p.syntax_error("var declaration not allowed in for initializer")
|
||||
if p.got(_Var) {
|
||||
p.syntax_error(fmt.Sprintf("var declaration not allowed in %s initializer", keyword.String()))
|
||||
}
|
||||
init = p.simpleStmt(nil, keyword == _For)
|
||||
// If we have a range clause, we are done (can only happen for keyword == _For).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue