Skip to content

cmd/compile: internal compiler error: bad Sym: have M, want foo #49017

Closed
@empire

Description

@empire

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

$ go version
go version devel go1.18-680caf1535 Sat Oct 16 14:50:21 2021 +0000 linux/amd64

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hossein/.cache/go-build"
GOENV="/home/hossein/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/hossein/.local/share/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/hossein/.local/share/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/hossein/Projects/Lab/Go/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/hossein/Projects/Lab/Go/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.18-680caf1535 Sat Oct 16 14:50:21 2021 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4045287131=/tmp/go-build -gno-record-gcc-switches"
GOROOT/bin/go version: go version devel go1.18-680caf1535 Sat Oct 16 14:50:21 2021 +0000 linux/amd64
GOROOT/bin/go tool compile -V: compile version devel go1.18-680caf1535 Sat Oct 16 14:50:21 2021 +0000
uname -sr: Linux 5.13.19-2-MANJARO
LSB Version:	n/a
Distributor ID:	ManjaroLinux
Description:	Manjaro Linux
Release:	21.1.5
Codename:	Pahvo
/usr/lib/libc.so.6: GNU C Library (GNU libc) release release version 2.33.

What did you do?

$ go build .

-- go.mod --
module example

go 1.18
-- main.go --
package main

type B[T interface{ M() }] T

func (b B[T]) foo() {
}

func main() {
        b := B[interface{ M() }](nil)
        b.foo()
}

What did you expect to see?

Either a successful build, or an error message

What did you see instead?

# example
./main.go:10:3: internal compiler error: bad Sym: have M, want foo

goroutine 1 [running]:
runtime/debug.Stack()
        /home/hossein/Projects/Lab/Go/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x14c000, 0xc0}, {0xcef6ef, 0x19}, {0xc0000b8c18, 0x2, 0x2})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/base/print.go:227 +0x1ca
cmd/compile/internal/noder.(*irgen).selectorExpr(0xc00014c000, {0xe39d60, 0x0}, {0xe3b248, 0xc00012a740}, 0xc0001141b0)
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/expr.go:312 +0xc8c
cmd/compile/internal/noder.(*irgen).expr0(0xc00014c000, {0xe3b248, 0xc00012a740}, {0xe3c330, 0xc0001141b0})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/expr.go:146 +0x532
cmd/compile/internal/noder.(*irgen).expr(0xc00014c000, {0xe3c330, 0xc0001141b0})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/expr.go:81 +0x5e8
cmd/compile/internal/noder.(*irgen).expr0(0xc00014c000, {0xe3b2c0, 0x0}, {0xe3be50, 0xc00012a200})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/expr.go:116 +0x5d9
cmd/compile/internal/noder.(*irgen).expr(0xc00014c000, {0xe3be50, 0xc00012a200})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/expr.go:81 +0x5e8
cmd/compile/internal/noder.(*irgen).stmt(0xc00014c000, {0xe3bfd0, 0xc000128240})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/stmt.go:40 +0xb6c
cmd/compile/internal/noder.(*irgen).stmts(0xc000131180, {0xc000128260, 0x2, 0xc0000b9670})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/stmt.go:19 +0xaf
cmd/compile/internal/noder.(*irgen).funcBody(0xc00014c000, 0xc00011e420, 0xc0000ab680, 0xc00012a0c0, 0xc00012a100)
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/func.go:45 +0x25f
cmd/compile/internal/noder.(*irgen).funcDecl.func1()
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/decl.go:143 +0xf5
cmd/compile/internal/noder.(*irgen).generate(0xc00014c000, {0xc00007eb80, 0x2, 0x203000})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/irgen.go:280 +0x227
cmd/compile/internal/noder.check2({0xc00007eb80, 0x2, 0x2})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/irgen.go:92 +0x16d
cmd/compile/internal/noder.LoadPackage({0xc00001e220, 0x2, 0x0})
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0xd0ee40)
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
        /home/hossein/Projects/Lab/Go/go/src/cmd/compile/main.go:55 +0xdd

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions