Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go/parser: confusing error message with missing "range" in for loop #7102

Closed
btracey opened this issue Jan 10, 2014 · 7 comments
Closed

go/parser: confusing error message with missing "range" in for loop #7102

btracey opened this issue Jan 10, 2014 · 7 comments
Assignees
Milestone

Comments

@btracey
Copy link
Contributor

@btracey btracey commented Jan 10, 2014

Relevant code:
http://play.golang.org/p/V_0vWTl3KE

Trying to range over anonymous structs but forgetting the range command, 
"for _, test := []struct{ " ...

Hitting "run" produces a  nice error message, 
"prog.go:6: assignment count mismatch: 2 = 1
prog.go:6: i, test := []struct { i int } literal used as value"

However, running format produces a much more cryptic message "6:6: expected
condition, found simple statement".  I get a similar error message running "go
test".
@minux
Copy link
Member

@minux minux commented Jan 10, 2014

Comment 1:

we probably can do better here. leaving to gri.
btw, go test first uses go/parser to parse the source, so it outputs the same
error message as gofmt.

Labels changed: added release-go1.3maybe, repo-main.

Owner changed to @griesemer.

@btracey
Copy link
Contributor Author

@btracey btracey commented Jan 10, 2014

Comment 2:

Thanks for the info. Is there a reason that the error messages from gc couldn't or
shouldn't be the same as those from go/parser?
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jan 10, 2014

Comment 3:

The parser is a different tool. The error messages are not synchronized. Some are better
in gc, some are better in go/parser.
@btracey
Copy link
Contributor Author

@btracey btracey commented Jan 10, 2014

Comment 4:

To rephrase my question, isn't it a desirable property that they have the same messages?
@griesemer
Copy link
Contributor

@griesemer griesemer commented Jan 11, 2014

Comment 5:

It's desirable but not easily possible. gc is using yacc, the go/parser is parsing in
recursive-descent fashion. That said, this issue is not the right place to discuss this.
@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 12, 2014

Comment 6:

https://golang.org/cl/56770045

Status changed to Started.

@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 12, 2014

Comment 7:

This issue was closed by revision 947aaf2.

Status changed to Fixed.

@btracey btracey added fixed labels Feb 12, 2014
@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.