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

Open
dotaheor opened this issue Mar 9, 2018 · 5 comments
Open

go/parser: redundant error message with unexpected comma #24327

dotaheor opened this issue Mar 9, 2018 · 5 comments
Labels
gopls/parsing Issues related to parsing / poor parser recovery. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

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

@andybons andybons added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 9, 2018
@dotaheor
Copy link
Author

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
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 Feedback is required from experts, contributors, and/or the community before a change can be made. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Mar 10, 2018
@griesemer griesemer added this to the Go1.11 milestone Mar 10, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 12, 2018
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 12, 2018
@griesemer
Copy link
Contributor

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
@gopherbot
Copy link

Change https://golang.org/cl/308612 mentions this issue: go/parser: improve error recovery in parseOperand

@adonovan adonovan added the gopls/parsing Issues related to parsing / poor parser recovery. label Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls/parsing Issues related to parsing / poor parser recovery. NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants