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

cmd/compile: dictionary for [...] should only use concrete types #52181

Open
pepjo opened this issue Apr 6, 2022 · 3 comments
Open

cmd/compile: dictionary for [...] should only use concrete types #52181

pepjo opened this issue Apr 6, 2022 · 3 comments
Labels
NeedsInvestigation
Milestone

Comments

@pepjo
Copy link

@pepjo pepjo commented Apr 6, 2022

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

$ go version
go version go1.18 linux/amd64

Does this issue reproduce with the latest release?

yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/peprf/.cache/go-build"
GOENV="/home/peprf/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/peprf/go/pkg/mod"
GONOPROXY="git.o-c.space*"
GONOSUMDB="git.o-c.space*"
GOOS="linux"
GOPATH="/home/peprf/go"
GOPRIVATE="git.o-c.space*"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/peprf/sdk/go1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/peprf/sdk/go1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/peprf/projects/satellite-gateway-service/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-build2035439223=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I used a complicated mess of generics, interfaces, and maps. Then, tried to run a unit test with the --race flag.

I've only managed to reproduce this using 2 different packages.

  • file at /[your project]/pkg/application/bug/bug_test.go

    package bug
    
    import (
        "testing"
    
        "[your project]/pkg/application/other"
    )
    
    type Provider interface {
        Run(other.FetcherByName[other.Something]) ([]byte, error)
    }
    
    func TestNothing(t *testing.T) {}
  • file at /[your project]/pkg/application/other/entities.go

    package other
    
    import "fmt"
    
    type Fetcher[thingType Something] struct {
        Thing thingType
    }
    
    func (a Fetcher[thingType]) Get() thingType {
        return a.Thing
    }
    
    type Something interface {
        Name() string
    }
    
    type FetcherByName[thingType Something] map[string]Fetcher[thingType]
    
    func (tp FetcherByName[thingType]) GetFetcherOfThing(t thingType) {
        fetcher := tp[t.Name()]
        fmt.Printf("The fetcher %v for things %s", fetcher, t.Name())
    }

With these files, run:

go test --race ./pkg/application/bug --short

What did you expect to see?

The same that I see without the --race flag:

ok      [your project]/pkg/application/bug     0.001s

What did you see instead?

the output of go test --race ./pkg/application/bug --short is:

# [your project]/pkg/application/bug [[your project]/pkg/application/bug.test]
<autogenerated>:1: internal compiler error: dictionary for Fetcher[go.shape.interface { Name() string }_0].Get should only use concrete types: go.shape.interface { Name() string }_0

Please file a bug report including a short program that triggers the error.
https://go.dev/issue/new
FAIL    [your project]/pkg/application/bug [build failed]
FAIL
@mengzhuo mengzhuo changed the title Compiler error: dictionary for [...] should only use concrete types cmd/compile: dictionary for [...] should only use concrete types Apr 6, 2022
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 6, 2022

@ianlancetaylor ianlancetaylor added the NeedsInvestigation label Apr 6, 2022
@ianlancetaylor ianlancetaylor added this to the Go1.19 milestone Apr 6, 2022
@ThinkChaos
Copy link

@ThinkChaos ThinkChaos commented May 4, 2022

Ran into this with go1.18.1 linux/amd64. Workaround is simple: retry, unfortunately for fixing this, it doesn't seem to occur often.

@pepjo
Copy link
Author

@pepjo pepjo commented May 7, 2022

At least in 1.18.0, retrying does not seem to solve the issue. We had to add an exception rule in our CI to allow the test to fail. Since I posted this, it has run hundreds of times and it has never worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

3 participants