-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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/types: incorrect type reported for comma-err C functions (manifests itself in IDEs) #47777
Comments
@AndSDev: Does clicking the "regenerate cgo definitions" button fix the problem? |
"regenerate cgo definitions" does not help. After switching the go version, VS Code asks to update the tools (in the notification) - after the update there is a problem. |
Can you please share your |
I too am seeing this problem (on macOS/Darwin) with gopls reporting a type mismatch for C function calls, expecting a bool return type rather than errno/error. Go 1.17, |
Interestingly, each function that is complaining about the mismatched error type has the C interface routine defined twice, one with two return values, and one with only one return value. |
If I select "Go to Definition" for C.proc_pidfdinfo called in the example above, VSCode takes me to this: //go:cgo_unsafe_args |
However, if I search in the file for proc_pidfdinfo, I also find this: //go:cgo_import_static _cgo_577eabb07159_C2func_proc_pidfdinfo //go:cgo_unsafe_args |
I reproduce this issue on a new user (all caches are empty, clear install of go 1.17). |
This is a regression in go/types in Go 1.17, introduced by me. Bisected to https://golang.org/cl/282193, where at call.go:305 I checked for commaerr operands, but overlooked that the operand mode had already been set to value on line 303. This needs to be fixed and backported to 1.17. @mdempsky might know more about the potential impact of this bug beyond gopls. CC @griesemer I have spotty internet right now, so might be slow to respond. |
I think |
I can reproduce this and have a fix. Will send out CL a bit later today. |
Change https://golang.org/cl/343809 mentions this issue: |
@gopherbot please backport to 1.17. This is a regression. |
Backport issue(s) opened: #47854 (for 1.17). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
The fix that closed this issue landed into master branch, which is where Go 1.18 development is happening, so moving this issue to the Go1.18 milestone. (The 1.17 backport issue #47854 is in 1.17.1 milestone.) |
Incorrect type for error in C-binding in IDE.
Go build / run works fine, but in IDE (VS Code) type of
err
isbool
instead oferror
.What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. Only the latest release is affected (1.17).
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Open the following in VS Code (main.go):
What did you expect to see?
Type of
err
iserror
.What did you see instead?
Type of
err
isbool
.IDE shows error:
cannot convert nil (untyped nil value) to bool
.The text was updated successfully, but these errors were encountered: