Skip to content

x/tools/go/analysis/passes/nilness: missing location for error in embedded struct #51986

@yuki2006

Description

@yuki2006

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

$ go version
go version go1.17.7 darwin/arm64

Does this issue reproduce with the latest release?

yes ( v0.1.10 )

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

go env Output
$ go env

GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/yuki/Library/Caches/go-build"
GOENV="/Users/yuki/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/yuki/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/yuki/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.7"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/yuki/gopath/src/go-test/go.mod"
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 arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/00/79n00m9j66zf77ppbmrzg_300000gn/T/go-build438069086=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go install golang.org/x/tools/go/analysis/passes/nilness/cmd/nilness@latest

put main.go

package main

import "fmt"

type dummy struct {
	innerDummy
}

type innerDummy struct {
	value int
}

func main() {
	var d *dummy
	fmt.Println(d.value)
}

nilness ./...

What did you expect to see?

The correct error location is displayed.

What did you see instead?

-: nil dereference in field selection

Metadata

Metadata

Assignees

No one assigned

    Labels

    AnalysisIssues related to static analysis (vet, x/tools/go/analysis)FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions