FAQ
Reviewers: rsc,

Message:
Hello rsc@golang.org (cc: golang-dev@googlegroups.com),

I'd like you to review this change to
https://code.google.com/p/go


Description:
go/parser: better error message for declaration error

Fixes issue 4616.

Please review this at https://codereview.appspot.com/7069049/

Affected files:
M src/pkg/go/parser/parser.go
M src/pkg/go/parser/short_test.go


Index: src/pkg/go/parser/parser.go
===================================================================
--- a/src/pkg/go/parser/parser.go
+++ b/src/pkg/go/parser/parser.go
@@ -149,7 +149,7 @@
}
}
} else {
- p.errorExpected(x.Pos(), "identifier")
+ p.errorExpected(x.Pos(), "identifier on left side of :=")
}
}
if n == 0 && p.mode&DeclarationErrors != 0 {
Index: src/pkg/go/parser/short_test.go
===================================================================
--- a/src/pkg/go/parser/short_test.go
+++ b/src/pkg/go/parser/short_test.go
@@ -70,6 +70,7 @@
`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) {

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedJan 7, '13 at 7:05p
activeJan 9, '13 at 7:38p
posts3
users2
websitegolang.org

2 users in discussion

Gri: 2 posts Russ Cox: 1 post

People

Translate

site design / logo © 2022 Grokbase