Commit 82accf44 authored by Robert Griesemer's avatar Robert Griesemer

go/parser: better error message for declaration error

Fixes #4616.

R=rsc
CC=golang-dev
https://golang.org/cl/7069049
parent f1cc0f44
......@@ -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 {
......
......@@ -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) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment