Skip to content

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

Open

Description

@dotaheor

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

Activity

  1. andybons commented on Mar 9, 2018

    @andybons
    Member

    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?

  2. added
    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
    on Mar 9, 2018
  3. dotaheor commented on Mar 10, 2018

    @dotaheor
    Author

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

  4. changed the title [-]cmd/fmt: imperfect error message[/-] [+]cmd/fmt: redundant error message[/+] on Mar 10, 2018
  5. mvdan commented on Mar 10, 2018

    @mvdan
    Member

    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.

  6. changed the title [-]cmd/fmt: redundant error message[/-] [+]go/printer: redundant error message with unexpected comma[/+] on Mar 10, 2018
  7. added
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    and removed
    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
    on Mar 10, 2018
  8. added this to the Go1.11 milestone on Mar 10, 2018
  9. added
    NeedsFixThe path to resolution is known, but the work has not been done.
    on Mar 12, 2018
  10. removed
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Mar 12, 2018
  11. griesemer commented on Apr 3, 2018

    @griesemer
    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.

  12. modified the milestones: Go1.11, Unplanned on Apr 3, 2018
  13. changed the title [-]go/printer: redundant error message with unexpected comma[/-] [+]go/parser: redundant error message with unexpected comma[/+] on Apr 9, 2018
  14. gopherbot commented on Apr 8, 2021

    @gopherbot
    Contributor

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.gopls/parsingIssues related to parsing / poor parser recovery.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions