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: fails to parse an invalid switch statement #29148

Open
stamblerre opened this issue Dec 7, 2018 · 2 comments
Open

go/parser: fails to parse an invalid switch statement #29148

stamblerre opened this issue Dec 7, 2018 · 2 comments
Labels
gopls/parsing Issues related to parsing / poor parser recovery. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@stamblerre
Copy link
Contributor

Repro case:

package main

import "go/ast"

func main() {
	var node ast.Node
	var lit *ast.CompositeLit
	switch n := node.(type) {
	case *ast.CompositeLit:
		lit = n
                lit.
	case *ast.KeyValueExpr:
	}
}

In this case, lit. case *ast.KeyValueExpr: gets parsed into an *ast.BadStmt. This is a problem for tools that need to work on broken code.

@stamblerre
Copy link
Contributor Author

/cc @ianthehat

@stamblerre stamblerre self-assigned this Dec 7, 2018
@mvdan
Copy link
Member

mvdan commented Dec 9, 2018

Could be interesting to see what cmd/compile/internal/syntax does here. As far as I've seen, it does a better job with edge cases and errors. Though it doesn't seem to have a BadStmt equivalent right now.

@ALTree ALTree added this to the Unplanned milestone Dec 13, 2018
@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 13, 2018
@stamblerre stamblerre removed their assignment Oct 22, 2020
@findleyr findleyr added the gopls/parsing Issues related to parsing / poor parser recovery. label Apr 8, 2022
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. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants