Skip to content

Staticheck panics for S1036 #806

@programmer04

Description

@programmer04

Howdy!

Version and environment:

staticcheck -version                                                                                                                                                                                                                                              
staticcheck 2020.1.4
staticcheck -debug.version                                                                                                                                                                                                                                        
staticcheck 2020.1.4

Compiled with Go version: go1.14.5
Main module:
        honnef.co/go/tools@v0.0.1-2020.1.4 (sum: h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=)
Dependencies:
        github.com/BurntSushi/toml@v0.3.1 (sum: h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=)
        golang.org/x/tools@v0.0.0-20191130070609-6e064ea0cf2d (sum: h1:/iIZNFGxc/a7C3yWjGcnboV+Tkc7mxr+p6fDztwoxuM=)
go version                                                                                                                                                                                                                                                        
go version go1.14.5 darwin/amd64
go env                                                                                                                                                                                                                                                            
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jakubwarczarek/Library/Caches/go-build"
GOENV="/Users/jakubwarczarek/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jakubwarczarek/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/lh/yzgq0xxj1kbc5cbchsjzps_40000gn/T/go-build208548302=/tmp/go-build -gno-record-gcc-switches -fno-common"

Commands:

go get honnef.co/go/tools/cmd/staticcheck
staticcheck

Output:

panic: unsupported comparison: []*ast.Field and []*ast.Field

goroutine 145 [running]:
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x15c5180, 0x1bd8d60, 0x15c5180, 0x1bd8d60, 0x0, 0x0, 0x2)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:245 +0x16bd
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x15c5180, 0x1bd8d60, 0x160fe20, 0xc0001fc7e0, 0x0, 0x0, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:159 +0x15d
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x160fe20, 0xc0001fc6c0, 0x160fe20, 0xc0001fc7e0, 0xc0001fc7e0, 0x196, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:138 +0x1215
honnef.co/go/tools/pattern.matchAST(0xc0004a61f0, 0x17a6400, 0xc0001c5620, 0x17a6400, 0xc0001c5700, 0x162ef01, 0xc0001c56c0, 0x1)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:343 +0x619
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x16103a0, 0xc0001c5620, 0x16103a0, 0xc0001c5700, 0xc0001c5700, 0x194, 0x1)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:183 +0xc27
honnef.co/go/tools/pattern.matchAST(0xc0004a61f0, 0x17a64c0, 0xc0001fc6f0, 0x17a64c0, 0xc0001fc810, 0x1610301, 0xc0001fc7b0, 0x1)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:343 +0x619
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x1610520, 0xc0001fc6f0, 0x1610520, 0xc0001fc810, 0xc0001fc810, 0x194, 0x1)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:183 +0xc27
honnef.co/go/tools/pattern.matchAST(0xc0004a61f0, 0x17a67c0, 0xc0001fc720, 0x17a67c0, 0xc0001fc840, 0x1, 0x0, 0xc000400000)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:343 +0x619
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x1610b20, 0xc0001fc720, 0x1610b20, 0xc0001fc840, 0xc0001fc840, 0x194, 0x20300000000000)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:183 +0xc27
honnef.co/go/tools/pattern.matchAST(0xc0004a61f0, 0x17a63c0, 0xc0001fc750, 0x17a63c0, 0xc0001fc870, 0x1, 0x0, 0x2)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:343 +0x619
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x1610320, 0xc0001fc750, 0x1610320, 0xc0001fc870, 0x17c0900, 0x15c8400, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:183 +0xc27
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x1610320, 0xc0001fc750, 0x15c8400, 0xc0004a8140, 0x1, 0x0, 0x8)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:215 +0x4ae
honnef.co/go/tools/pattern.Binding.Match(0x16d4c57, 0x9, 0x0, 0x0, 0xc0004a61f0, 0x15c8400, 0xc0004a8140, 0x16561a0, 0xc0004a8101, 0x7a80168)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:358 +0xcb
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x16561a0, 0xc000183480, 0x15c8400, 0xc0004a8140, 0xc0004a8140, 0xc000187f00, 0x197)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:167 +0xd06
honnef.co/go/tools/pattern.matchNodeAST(0xc0004a61f0, 0x17a7a80, 0xc0001922d0, 0x160f4a0, 0xc000187f00, 0x1, 0x0, 0x1)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:287 +0x646
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x165a0c0, 0xc0001922d0, 0x160f4a0, 0xc000187f00, 0x1610320, 0xc0001fc750, 0x1)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:172 +0xc9f
honnef.co/go/tools/pattern.matchNodeAST(0xc0004a61f0, 0x17a7a80, 0xc0001922d0, 0x15c84c0, 0xc0004a8120, 0x1, 0x18, 0x100000000000196)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:258 +0xcf
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x165a0c0, 0xc0001922d0, 0x15c84c0, 0xc0004a8120, 0x17c0900, 0x160f7a0, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:172 +0xc9f
honnef.co/go/tools/pattern.Binding.Match(0x16d4c47, 0x3, 0x17a7a80, 0xc0001922d0, 0xc0004a61f0, 0x15c84c0, 0xc0004a8120, 0x16561a0, 0x101, 0x7a80168)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:368 +0x1aa
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x16561a0, 0xc0001834c0, 0x15c84c0, 0xc0004a8120, 0x165fc00, 0xc000187f40, 0x199)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:167 +0xd06
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x16561a0, 0xc0001834c0, 0x160f7a0, 0xc0001fc8a0, 0xc0001fc8a0, 0xc000187f68, 0x196)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:154 +0x1070
honnef.co/go/tools/pattern.matchNodeAST(0xc0004a61f0, 0x17a8040, 0xc000112a80, 0x16101a0, 0xc000187f40, 0x1, 0xc0004a2240, 0xc000510710)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:287 +0x646
honnef.co/go/tools/pattern.match(0xc0004a61f0, 0x1664540, 0xc000112a80, 0x16101a0, 0xc000187f40, 0x160a980, 0x163e5f8, 0x163e5d0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:172 +0xc9f
honnef.co/go/tools/pattern.Or.Match(0xc0001923c0, 0x3, 0x3, 0xc0004a61e0, 0x16101a0, 0xc000187f40, 0x163e580, 0x1, 0x7a80030)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:478 +0xc0
honnef.co/go/tools/pattern.match(0xc0004a61e0, 0x163e580, 0xc000183860, 0x16101a0, 0xc000187f40, 0x203000, 0xc000510aa0, 0x1007e85)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:167 +0xd06
honnef.co/go/tools/pattern.(*Matcher).Match(...)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/pattern/match.go:110
honnef.co/go/tools/lint/lintdsl.Match(0xc0004a4280, 0x17a8300, 0xc000183860, 0xc000033140, 0x3, 0x4, 0x17a6300, 0xc000187f40, 0xc000201198, 0xc00031ad80)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/lint/lintdsl/lintdsl.go:27 +0xcc
honnef.co/go/tools/simple.CheckUnnecessaryGuard.func1(0x17a6300, 0xc000187f40)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/simple/lint.go:1751 +0x82
golang.org/x/tools/go/ast/inspector.(*Inspector).Preorder(0xc000309400, 0xc000510bd8, 0x1, 0x1, 0xc0004d5be8)
        /Users/jakubwarczarek/go/pkg/mod/golang.org/x/tools@v0.0.0-20191130070609-6e064ea0cf2d/go/ast/inspector/inspector.go:77 +0x9f
honnef.co/go/tools/code.Preorder(...)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/code/code.go:480
honnef.co/go/tools/simple.CheckUnnecessaryGuard(0xc0004a4280, 0xee258f8, 0x1bace20, 0xc0004ac2b8, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/simple/lint.go:1760 +0xc5
honnef.co/go/tools/lint.(*Runner).runAnalysisUser(0xc00027dbc0, 0xc0004a4280, 0xc0001971d0, 0x0, 0x0, 0x0, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/lint/runner.go:494 +0x2af
honnef.co/go/tools/lint.(*Runner).runAnalysis(0xc00027dbc0, 0xc0001971d0, 0x0, 0x0, 0x0, 0x0)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/lint/runner.go:374 +0x574
honnef.co/go/tools/lint.(*Runner).processPkg.func3(0xc0001f01e0, 0xc0001b8360, 0xc000238340, 0xc00027dbc0, 0xc0001971d0, 0xc0001bd600, 0x88, 0x88, 0x22)
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/lint/runner.go:913 +0x79
created by honnef.co/go/tools/lint.(*Runner).processPkg
        /Users/jakubwarczarek/go/pkg/mod/honnef.co/go/tools@v0.0.1-2020.1.4/lint/runner.go:908 +0x9f3

Code which gives the ability to reproduce above behavior:

package main

func main() {
	obj := make(map[string]interface{})
	obj["schema"] = make(map[string]interface{})

	if _, ok := obj["schema"].(map[string]interface{})["items"]; ok {
		obj["schema"].(map[string]interface{})["version"] = 1
	}
}

Originally it was spotted during usage of golangci-lint and reported to in issue golangci/golangci-lint#1278

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions