dominikh / go-tools

Staticcheck - The advanced Go linter
https://staticcheck.dev
MIT License
6.21k stars 377 forks source link

"missing function body" should not happen with //go:wasmimport #1579

Closed mattjohnsonpint closed 2 months ago

mattjohnsonpint commented 3 months ago

Any function tagged with //go:wasmimport (added in Go 1.21 and also TinyGo) should not have a body, yet staticcheck thinks that it needs one.

image

See: https://go.dev/blog/wasi#wrapping-wasm-functions-in-go-with-gowasmimport

There's also an older syntax only supported by TinyGo, though I'd be happy with just the official syntax supported. See https://github.com/tinygo-org/tinygo/issues/4372

Checked with both 2023.1.7 and 2024.1rc1, with same results. I guess it just hasn't been added yet. Would be good to support before the 2024 version has its final release. Thanks.

Thanks.

dominikh commented 3 months ago

As far as I can tell from that screenshot, that error is reported to us either by go build or by go/types, Staticcheck is merely forwarding it. You'll have to make sure you're running the expected version of Staticcheck, built and running with the expected version of Go.

mattjohnsonpint commented 2 months ago

I've been using the workaround described in https://github.com/golangci/golangci-lint/issues/4956#issuecomment-2310719310

It works well, so I don't think there is anything else to do here. Thanks.