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

Comments

@evmar
Copy link

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

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

@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
Development

No branches or pull requests

3 participants