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/internal/lsp: AutoCompletion Does Not Work Inside Goroutines #30805

Closed
marwan-at-work opened this issue Mar 13, 2019 · 4 comments
Closed
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@marwan-at-work
Copy link
Contributor

Info

  • Go version: 1.12 darwin
  • Editor: VSCode
  • gopls version: e65039

reproduce

- mkdir temp
- cd temp
- go mod init temp
- touch main.go

inside main.go open VSCode and type the following main.go file

package main

import (
  "net/http"
)

func main() {
  go func() {
    http.
  }()
}

Note that because http. was typed inside the anonymous goroutine, nothing gets auto-completed. However, if you type http. outside of that goroutine, then things work well.

@gopherbot gopherbot added this to the Unreleased milestone Mar 13, 2019
@marwan-at-work marwan-at-work added the gopls Issues related to the Go language server, gopls. label Mar 13, 2019
@anjmao
Copy link

anjmao commented Mar 14, 2019

It looks like a bug of astutil.PathEnclosingInterval method since for this case it returns *ast.BlockStmt with wrong inner nodes.

Example:

package source

import (
  "net/http"
  "fmt"
)

func fn1() {
	go func() {
		http.<>
	}()
}

func fn2() {
	if 1 == 2 {
		fmt.Println("great")
	}
}

AST

[]ast.Node (len = 3) {
     1  .  0: *ast.BlockStmt {
     2  .  .  Lbrace: /go/src/golang.org/x/tools/internal/lsp/source/t.go:8:12
     3  .  .  List: []ast.Stmt (len = 3) {
     4  .  .  .  0: *ast.BadStmt {
     5  .  .  .  .  From: /go/src/golang.org/x/tools/internal/lsp/source/t.go:9:2
     6  .  .  .  .  To: /go/src/golang.org/x/tools/internal/lsp/source/t.go:9:4
     7  .  .  .  }
     8  .  .  .  1: *ast.ExprStmt {
     9  .  .  .  .  X: *ast.BadExpr {
    10  .  .  .  .  .  From: /go/src/golang.org/x/tools/internal/lsp/source/t.go:14:1
    11  .  .  .  .  .  To: /go/src/golang.org/x/tools/internal/lsp/source/t.go:14:13
    12  .  .  .  .  }
    13  .  .  .  }
    14  .  .  .  2: *ast.IfStmt {
    15  .  .  .  .  If: /go/src/golang.org/x/tools/internal/lsp/source/t.go:15:2
    16  .  .  .  .  Init: nil
    17  .  .  .  .  Cond: *ast.BinaryExpr {
    18  .  .  .  .  .  X: *ast.BasicLit {
    19  .  .  .  .  .  .  ValuePos: /go/src/golang.org/x/tools/internal/lsp/source/t.go:15:5
    20  .  .  .  .  .  .  Kind: INT
    21  .  .  .  .  .  .  Value: "1"
    22  .  .  .  .  .  }
    23  .  .  .  .  .  OpPos: /go/src/golang.org/x/tools/internal/lsp/source/t.go:15:7
    24  .  .  .  .  .  Op: ==
    25  .  .  .  .  .  Y: *ast.BasicLit {
    26  .  .  .  .  .  .  ValuePos: /go/src/golang.org/x/tools/internal/lsp/source/t.go:15:10
    27  .  .  .  .  .  .  Kind: INT
    28  .  .  .  .  .  .  Value: "2"
    29  .  .  .  .  .  }
    30  .  .  .  .  }
    31  .  .  .  .  Body: *ast.BlockStmt {
    32  .  .  .  .  .  Lbrace: /go/src/golang.org/x/tools/internal/lsp/source/t.go:15:12

@zmb3
Copy link
Contributor

zmb3 commented Mar 15, 2019

Duplicate of #29313?

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 12, 2019
@bcmills
Copy link
Contributor

bcmills commented Apr 12, 2019

@stamblerre, is this a duplicate?

@stamblerre
Copy link
Contributor

I believe so. Closing in favor of that issue.

@golang golang locked and limited conversation to collaborators May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. 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

6 participants