1
0
mirror of https://github.com/golang/go synced 2024-11-26 16:46:58 -07:00

go/parser: better error message for declaration error

Fixes #4616.

R=rsc
CC=golang-dev
https://golang.org/cl/7069049
This commit is contained in:
Robert Griesemer 2013-01-09 11:31:57 -08:00
parent f1cc0f44e3
commit 82accf44bf
2 changed files with 2 additions and 1 deletions

View File

@ -149,7 +149,7 @@ func (p *parser) shortVarDecl(decl *ast.AssignStmt, list []ast.Expr) {
}
}
} else {
p.errorExpected(x.Pos(), "identifier")
p.errorExpected(x.Pos(), "identifier on left side of :=")
}
}
if n == 0 && p.mode&DeclarationErrors != 0 {

View File

@ -70,6 +70,7 @@ var invalids = []string{
`package p; func f() { select { case _ <- chan /* ERROR "expected expression" */ int: } };`,
`package p; func f() { _ = (<-<- /* ERROR "expected 'chan'" */ chan int)(nil) };`,
`package p; func f() { _ = (<-chan<-chan<-chan<-chan<-chan<- /* ERROR "expected channel type" */ int)(nil) };`,
`package p; func f() { var t []int; t /* ERROR "expected identifier on left side of :=" */ [0] := 0 };`,
}
func TestInvalid(t *testing.T) {