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

x/tools/gopls: stack overflow in parser.go:fix function #34353

stamblerre opened this issue Sep 17, 2019 · 1 comment

x/tools/gopls: stack overflow in parser.go:fix function #34353

stamblerre opened this issue Sep 17, 2019 · 1 comment


Copy link

@stamblerre stamblerre commented Sep 17, 2019

To reproduce:

func (s *Server) _() {
	switch true {
	case true:
		go s.<>

/cc @muirrn

@gopherbot gopherbot added this to the Unreleased milestone Sep 17, 2019
@golang golang deleted a comment from gopherbot Sep 17, 2019

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Sep 18, 2019

Change mentions this issue: internal/lsp: fix infinite recursion while fixing AST

clintjedwards added a commit to clintjedwards/tools that referenced this issue Sep 25, 2019
We were recursing infinitely in cases like this:

switch true {
case true:
	go foo.F<>

There were three things that came together to cause this:
1. We recently starting recursively fixing broken go/defer statements.
2. In this case we were failing to swap in the correct ast.Node in for
   the *ast.BadStmt because we were only looking
   for *ast.BlockStmt (and *ast.CaseStmt has no block).
3. After 2), we weren't returning an error so the fix() code thought
   it should recurse.

Fix 2) by using reflection to swap AST nodes in a generic way. Perhaps
a bit overkill in this case, but I happened to have already written
this for an upcoming change, so I just pulled it in to fix this bug.

Fix 3) by returning an error if we fail to swap the AST nodes.

Fixes golang/go#34353.

Change-Id: I17ff1afd52ae165c0ba9de5820dcec4cb7d756cb
Run-TryBot: Rebecca Stambler <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Rebecca Stambler <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.