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: reports incorrect type for cgo errno value #49777

Closed
minty99 opened this issue Nov 24, 2021 · 1 comment
Closed

x/tools/gopls: reports incorrect type for cgo errno value #49777

minty99 opened this issue Nov 24, 2021 · 1 comment
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@minty99
Copy link

minty99 commented Nov 24, 2021

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

$ go version
go version go1.17 darwin/amd64

Does this issue reproduce with the latest release?

not sure

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/andrew/Library/Caches/go-build"
GOENV="/Users/andrew/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andrew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andrew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.17/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.17/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/zd/drxy0rp51t9230whvm__wfb00000gn/T/go-build245735751=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I wrote this program to test error handling in cgo,

package main

/*
#include <stdio.h>
#include <errno.h>

int f(int n) {
	errno = 1;
	return n * 100;
}
*/
import "C"
import "fmt"

func main() {
	ans, err := C.f(C.int(100))
	fmt.Println(ans)
	fmt.Println(err)
}

Bug

I found the language server says type of err is bool. It actually is syscall.Errno.
I am using VSCode editor and I know this can be problem of vscode plugin, but I don't have knowledge to check what tool is buggy, so I report here first.
Screen Shot 2021-11-24 at 1 57 12 PM

@minty99 minty99 changed the title Cgo errno handling protocol error Cgo errno handling type check bug Nov 24, 2021
@ianlancetaylor ianlancetaylor changed the title Cgo errno handling type check bug x/tools/gopls: reports incorrect type for cgo errno value Nov 24, 2021
@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 Nov 24, 2021
@gopherbot gopherbot added this to the Unreleased milestone Nov 24, 2021
@findleyr
Copy link
Contributor

Hi, thanks for reporting, and sorry for the breakage. This was a regression in Go 1.17: #47854, fixed in Go 1.17.1. You can fix it by updating your Go version.

@golang golang locked and limited conversation to collaborators Nov 24, 2022
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants