Skip to content

go/parser: fails when a valid function declaration follows an broken one #29145

Open

Description

@stamblerre

Repro case:

package main

type e struct {
	error
}

func (*e) random() {}

func main() {
	var diags []error
	for _, err := range diags {
		handled := handle(err)
                handled.
	}
}

func handle(err error) *e {
	return &e{err}
}

The selector with no "Sel" field breaks parsing in the main function, causing the code below it to fail parsing. The handle function never gets registered as a function declaration. Moving the handle function above the main function causes this code to type-check as expected. This poses a problem for editor-integrated tools that need to work on broken code.

Activity

  1. self-assigned this
    on Dec 7, 2018
  2. stamblerre commented on Dec 7, 2018

    @stamblerre
    ContributorAuthor
  3. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Dec 13, 2018
  4. added this to the Unplanned milestone on Dec 13, 2018
  5. removed their assignment
    on Oct 22, 2020
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

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions