aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/syntax/parser.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2017-02-13 15:08:04 -0800
committerRobert Griesemer <gri@golang.org>2017-02-13 23:15:32 +0000
commitefb3cab960e7cec3262f41705ec5b69431815411 (patch)
tree72a59425d1c48c6c19fc43fc712dbb977420de43 /src/cmd/compile/internal/syntax/parser.go
parentf823d305141be6b18f82c875652019eccd0c6679 (diff)
downloadgo-efb3cab960e7cec3262f41705ec5b69431815411.tar.xz
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>
Diffstat (limited to 'src/cmd/compile/internal/syntax/parser.go')
-rw-r--r--src/cmd/compile/internal/syntax/parser.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go
index e4aaa12ae5..d7f542e609 100644
--- a/src/cmd/compile/internal/syntax/parser.go
+++ b/src/cmd/compile/internal/syntax/parser.go
@@ -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).