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

cmd/gofmt: generate a better error message for composite literals that need to be parenthesized #6052

Closed
lexprfuncall opened this issue Aug 6, 2013 · 8 comments

Comments

@lexprfuncall
Copy link

Compile and run the following program

  package main

  type S struct {}

  func main() {
      if x := &S{}; true {
          println("true")
      }
  }

  Also available here:

  http://play.golang.org/p/pgwmzxP81l


What do you see instead?

  "prog.go:7:5: expected condition, found simple statement (and 1 more errors)"

  The resolution is to wrap the &S{} in parenthesis. I believe this error message is somwhat opaque and we could do a better job notifying the user about the grammar ambiguity.
@robpike
Copy link
Contributor

robpike commented Aug 16, 2013

Comment 2:

Won't happen for 1.2

Labels changed: added go1.3maybe, removed go1.2maybe.

@robpike
Copy link
Contributor

robpike commented Aug 20, 2013

Comment 3:

Labels changed: removed go1.3maybe.

@griesemer
Copy link
Contributor

Comment 4:

This is a go/parser issue.

Owner changed to @griesemer.

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 5:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 6:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 7:

Labels changed: added repo-main.

@griesemer
Copy link
Contributor

Comment 8:

https://golang.org/cl/49740045

Status changed to Started.

@griesemer
Copy link
Contributor

Comment 9:

This issue was closed by revision 8a089c0.

Status changed to Fixed.

@golang golang locked and limited conversation to collaborators Jun 24, 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
Development

No branches or pull requests

5 participants