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:
parent
f1cc0f44e3
commit
82accf44bf
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user