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: redundant error message with unexpected comma #24327

Open
dotaheor opened this Issue Mar 9, 2018 · 4 comments

Comments

Projects
None yet
6 participants
@dotaheor
Copy link

dotaheor commented Mar 9, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

yes

What did you do?

package main

func f() {}

func main() {
	f(,)
}

/*
...
*/  // missing ',' in argument list

What did you expect to see?

[edit]

$ go fmt a.go
a.go:6:4: expected operand, found ','

What did you see instead?

$ go fmt a.go
a.go:6:4: expected operand, found ','
a.go:11:37: missing ',' in argument list
@andybons

This comment has been minimized.

Copy link
Member

andybons commented Mar 9, 2018

I’m confused. Your expected output isn’t sufficient (nothing after “found”).

Are you saying that it should not say a.go:11:37: missing ',' in argument list at all but the first message (a.go:6:4: expected operand, found ',') is OK?

@dotaheor

This comment has been minimized.

Copy link

dotaheor commented Mar 10, 2018

yes.
I modified the expected output.
Looks the comment block doesn't matter for the redundant error message.

@dotaheor dotaheor changed the title cmd/fmt: imperfect error message cmd/fmt: redundant error message Mar 10, 2018

@mvdan

This comment has been minimized.

Copy link
Member

mvdan commented Mar 10, 2018

This is another case of go/parser being behind cmd/compile/internal/syntax in terms of reporting errors to humans.

$ gofmt f4.go
f4.go:6:4: expected operand, found ','
f4.go:7:3: missing ',' in argument list
$ go build f4.go
# command-line-arguments
./f4.go:6:4: syntax error: unexpected comma, expecting expression

I'll let @griesemer decide what to do.

@mvdan mvdan changed the title cmd/fmt: redundant error message go/printer: redundant error message with unexpected comma Mar 10, 2018

@mvdan mvdan added NeedsDecision and removed WaitingForInfo labels Mar 10, 2018

@griesemer griesemer added this to the Go1.11 milestone Mar 10, 2018

@griesemer

This comment has been minimized.

Copy link
Contributor

griesemer commented Apr 3, 2018

Marking as unplanned. go/parser is likely falling behind the compiler due to the compiler's parser (package syntax) being actively improved whenever we run into unsatisfying error messages. It's fairly time-consuming to back-port those fixes because the parsers don't have the same structure, and small local changes sometimes have unexpected consequences with respect to error handling (hence those changes, even if small, are time-consuming to get right).

Ideally, in the long run we should migrate to package syntax. Failing that, one option might be to replace go/parser with the syntax package parser while keeping the same API. That might be not too hard since the syntax trees are reasonably close.

@griesemer griesemer modified the milestones: Go1.11, Unplanned Apr 3, 2018

@mvdan mvdan changed the title go/printer: redundant error message with unexpected comma go/parser: redundant error message with unexpected comma Apr 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment