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

Generics are not handled correctly #2954

Closed
4 tasks done
nekohasekai opened this issue Jul 2, 2022 · 2 comments
Closed
4 tasks done

Generics are not handled correctly #2954

nekohasekai opened this issue Jul 2, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@nekohasekai
Copy link

Welcome

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

Code:

package main

import "fmt"

func main() {
	c := a("hello linter", b[string])
	println(c)
}

func a[T any, N any](x T, y func(T) N) N {
	return y(x)
}

func b[T any](x T) string {
	return fmt.Sprint(x)
}

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.46.2 built from (unknown, mod sum: "h1:o90t/Xa6dhJbvy8Bz2RpzUXqrkigp19DLStMolTZbyo=") on (unknown)

Configuration file

No configuration file

Go environment

$ go version && go env
go version go1.18.3 linux/amd64
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/sekai/.cache/go-build"
GOENV="/home/sekai/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/sekai/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/sekai/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/sekai/Projects/test/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2319946798=/tmp/go-build -gno-record-gcc-switches"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /home/sekai/Projects/test /home/sekai/Projects /home/sekai /home /] 
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck] 
INFO [loader] Go packages loading at mode 575 (name|types_sizes|compiled_files|deps|imports|exports_file|files) took 81.622394ms 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 161.476µs 
INFO [linters context/goanalysis] analyzers took 1.423912407s with top 10 stages: buildir: 1.001566837s, inspect: 72.982132ms, fact_deprecated: 71.724064ms, fact_purity: 67.705198ms, printf: 62.759387ms, ctrlflow: 45.818369ms, nilness: 43.299855ms, SA5012: 31.997279ms, typedness: 15.101725ms, S1038: 685.921µs 
ERRO [runner] Panic: S1029: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR: goroutine 1180 [running]:
runtime/debug.Stack()
        /home/sekai/go/go1.19beta1/src/runtime/debug/stack.go:24 +0x65
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func1()
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/golinters/goanalysis/runner_action.go:101 +0x155
panic({0x14fa740, 0xc0021e0e10})
        /home/sekai/go/go1.19beta1/src/runtime/panic.go:884 +0x212
honnef.co/go/tools/internal/sharedcheck.CheckRangeStringRunes(0xc00064c680)
        /home/sekai/go/pkg/mod/honnef.co/go/tools@v0.3.1/internal/sharedcheck/lint.go:24 +0x17b
honnef.co/go/tools/simple.CheckRangeStringRunes(0x14d7500?)
        /home/sekai/go/pkg/mod/honnef.co/go/tools@v0.3.1/simple/lint.go:1630 +0x19
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyze(0xc0015ae480)
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/golinters/goanalysis/runner_action.go:187 +0x9d6
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe.func2()
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/golinters/goanalysis/runner_action.go:105 +0x1d
github.com/golangci/golangci-lint/pkg/timeutils.(*Stopwatch).TrackStage(0xc00051d900, {0x162162b, 0x5}, 0xc0015ce748)
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/timeutils/stopwatch.go:111 +0x4a
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*action).analyzeSafe(0xc001394e40?)
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/golinters/goanalysis/runner_action.go:104 +0x85
github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze.func2(0xc0015ae480)
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/golinters/goanalysis/runner_loadingpackage.go:80 +0xb4
created by github.com/golangci/golangci-lint/pkg/golinters/goanalysis.(*loadingPackage).analyze
        /home/sekai/go/pkg/mod/github.com/golangci/golangci-lint@v1.46.2/pkg/golinters/goanalysis/runner_loadingpackage.go:75 +0x1eb 
WARN [runner] Can't run linter goanalysis_metalinter: goanalysis_metalinter: S1029: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR 
WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649. 
INFO [runner] processing took 32.967µs with stages: max_same_issues: 2.445µs, max_from_linter: 1.956µs, path_prettifier: 1.955µs, filename_unadjuster: 1.886µs, severity-rules: 1.886µs, nolint: 1.886µs, exclude: 1.886µs, skip_dirs: 1.886µs, exclude-rules: 1.885µs, identifier_marker: 1.467µs, max_per_file_from_linter: 1.467µs, source_code: 1.467µs, cgo: 1.467µs, path_prefixer: 1.467µs, autogenerated_exclude: 1.467µs, diff: 1.397µs, sort_results: 1.397µs, skip_files: 1.396µs, uniq_by_line: 1.396µs, path_shortener: 908ns 
INFO [runner] linters took 1.160564934s with stages: goanalysis_metalinter: 1.160379573s, structcheck: 18.928µs 
ERRO Running error: 1 error occurred:
        * can't run linter goanalysis_metalinter: goanalysis_metalinter: S1029: package "main" (isInitialPkg: true, needAnalyzeSource: true): interface conversion: interface {} is nil, not *buildir.IR
 
INFO Memory: 14 samples, avg is 176.1MB, max is 248.1MB 
INFO Execution took 1.249802305s 

Code example or link to a public repository

No link

@nekohasekai nekohasekai added the bug Something isn't working label Jul 2, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Jul 2, 2022

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

@ldez
Copy link
Member

ldez commented Jul 2, 2022

duplicate of #2859

@ldez ldez closed this as completed Jul 2, 2022
@ldez ldez added duplicate This issue or pull request already exists and removed bug Something isn't working labels Jul 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants