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: add clear error on missing , at end of line in composite literal #3008

Closed
rsc opened this issue Feb 13, 2012 · 2 comments
Closed

go/parser: add clear error on missing , at end of line in composite literal #3008

rsc opened this issue Feb 13, 2012 · 2 comments
Assignees

Comments

@rsc
Copy link
Contributor

@rsc rsc commented Feb 13, 2012

$ cat x.go
package main

var x = []int{
    1
}
$ gofmt x.go
x.go:4:3: expected '}', found newline
x.go:5:1: expected declaration, found '}'
$ 

Since this is such a common beginning Go programmer mistake,
go/parser should diagnose it directly, saying something like:

x.go:4:3: missing ',' before newline in composite literal
@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 14, 2012

Comment 1:

See: http://golang.org/cl/5660046
For:
package p
var _ = []int{
    1
}
func _() {
    f(
        1
    )
}
The error message are now:
gofmt x.go
x.go:4:3: missing ',' before newline in composite literal
x.go:9:4: missing ',' before newline in argument list
@griesemer
Copy link
Contributor

@griesemer griesemer commented Feb 14, 2012

Comment 2:

This issue was closed by revision e3f11b3.

Status changed to Fixed.

@rsc rsc added fixed labels Feb 14, 2012
@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
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.