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

Open
wingyplus opened this issue Feb 18, 2020 · 6 comments

Comments

@wingyplus
Copy link
Contributor

@wingyplus wingyplus commented Feb 18, 2020

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
@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

This comment has been minimized.

Copy link
Contributor Author

@wingyplus wingyplus commented Feb 18, 2020

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

This comment has been minimized.

Copy link
Contributor Author

@wingyplus wingyplus commented Feb 18, 2020

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

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

This comment has been minimized.

Copy link
Contributor Author

@wingyplus wingyplus commented Feb 20, 2020

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

@ridersofrohan

This comment has been minimized.

Copy link

@ridersofrohan 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

This comment has been minimized.

Copy link
Contributor Author

@wingyplus wingyplus commented Mar 3, 2020

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

This comment has been minimized.

Copy link
Contributor

@stamblerre stamblerre commented Mar 3, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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