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: bad gofmt error message on extra comma in struct type #12437

Closed
evmar opened this issue Sep 1, 2015 · 1 comment
Closed

go/parser: bad gofmt error message on extra comma in struct type #12437

evmar opened this issue Sep 1, 2015 · 1 comment
Assignees

Comments

@evmar
Copy link

@evmar evmar commented Sep 1, 2015

On some bad code, gofmt gives a confusing error while the compiler gives a nice one.

Online demo at http://play.golang.org/p/htmZpN6HcY (click "format"), also inlined here to keep the bug self-contained.

package main

import "fmt"

func main() {
    x := struct {
        foo string,
    }{3}
}

The issue is the comma.

Format says 6:7: expected expression (and 3 more errors), which points at the "struct" keyword.

Run says prog.go:7: syntax error: unexpected comma, expecting }, which is a good error message.

@evmar evmar changed the title confusing gofmt error message on bad code Bad gofmt error message on extra comma in struct type Sep 1, 2015
@bradfitz bradfitz changed the title Bad gofmt error message on extra comma in struct type go/parser: bad gofmt error message on extra comma in struct type Sep 1, 2015
@gopherbot
Copy link

@gopherbot gopherbot commented Sep 14, 2015

CL https://golang.org/cl/14564 mentions this issue.

@griesemer griesemer closed this in 8fab292 Sep 14, 2015
@golang golang locked and limited conversation to collaborators Sep 22, 2016
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
3 participants
You can’t perform that action at this time.