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: function signature show target alias not type alias when hover on function #37283

Closed
wingyplus opened this issue Feb 18, 2020 · 7 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@wingyplus
Copy link
Contributor

What version of Go are you using (go version)?

$ go version
go version devel +4b4370066f Mon Dec 30 09:34:53 2019 +0000 darwin/amd64
$ gopls version
golang.org/x/tools/gopls v0.3.1
    golang.org/x/tools/gopls@v0.3.1 h1:yNTWrf4gc4Or0UecjOas5pzOa3BL0WDDyKDV4Wz5VaM=

What did you do?

I used gopls with emacs lsp-mode and hover on function name FromGeo in h3 library.

What did you expect to see?

function signature on hover should return h3.H3Index

What did you see instead?

It's returns h3._Ctype_ulonglong

Screen Shot 2563-02-18 at 21 33 40

@gopherbot gopherbot added this to the Unreleased milestone Feb 18, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 18, 2020
@wingyplus wingyplus changed the title x/tools/gopls: function signature returns target type alias not type alias x/tools/gopls: function signature show target alias not type alias Feb 18, 2020
@wingyplus wingyplus changed the title x/tools/gopls: function signature show target alias not type alias x/tools/gopls: function signature show target alias not type alias when hover on function Feb 18, 2020
@wingyplus
Copy link
Contributor Author

For more information h3.H3Index alias from type C.H3Index (https://pkg.go.dev/github.com/uber/h3-go?tab=doc#H3Index) and C.H3Index is type uint64_t in h3 C library here.

@wingyplus
Copy link
Contributor Author

Oh, or perhaps it's not work with cgo?

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v0.4.0 Feb 18, 2020
@wingyplus
Copy link
Contributor Author

it's seems it received _Ctype_ulonglong after calling types.Checker.Check() in L381

@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 26, 2020
@ridersofrohan
Copy link

ridersofrohan commented Mar 2, 2020

I looked into this more and found the same thing that @wingyplus did, the typechecker is sending back the target alias rather than the type alias. Not sure how gopls can handle this since it just displays the information directly from go/types

@wingyplus
Copy link
Contributor Author

Another reproduce case is:

// source
package main

// #include<stdint.h>
// typedef uint64_t Index;
import "C"
import "fmt"

type Index = C.Index

func main() {
	var a Index
	fmt.Println(a)
}

After request autocomplete I got Index is type uint64.

Screen Shot 2563-03-03 at 17 38 51

@stamblerre
Copy link
Contributor

We will probably need to do the same thing that we did for placeholders here (https://golang.org/cl/208497).

@stamblerre stamblerre added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Mar 3, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.4.0, gopls/v0.5.0 Apr 2, 2020
@gopherbot
Copy link

Change https://golang.org/cl/229319 mentions this issue: internal/lsp: correctly handle type aliases when formatting

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. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants