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: internal compiler error: Type.Elem TYPEPARAM #48609

Closed
mattn opened this issue Sep 24, 2021 · 2 comments
Closed

cmd/compile: internal compiler error: Type.Elem TYPEPARAM #48609

mattn opened this issue Sep 24, 2021 · 2 comments
Assignees
Labels
Milestone

Comments

@mattn
Copy link
Member

@mattn mattn commented Sep 24, 2021

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

$ go version
go version devel go1.18-fe8347b61a Fri Sep 24 10:51:48 2021 +0000 windows/amd64

Does this issue reproduce with the latest release?

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

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\mattn\AppData\Local\go-build
set GOENV=C:\Users\mattn\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\mattn\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\mattn\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\dev\go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\dev\go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.18-fe8347b61a Fri Sep 24 10:51:48 2021 +0000
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\mattn\go\src\github.com\mattn\go-generics-example\constraints\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\mattn\AppData\Local\Temp\go-build2745930428=/tmp/go-build -gno-record-gcc-switches

What did you do?

Compile this code

package main

import (
    "constraints"
    "context"
    "fmt"
)

func makeChan[T constraints.Chan[E], E any](ctx context.Context, arr []E) T {
    ch := make(T)
    go func() {
        defer close(ch)
        for _, v := range arr {
            select {
            case <-ctx.Done():
                return
            default:
            }
            ch <- v
        }
    }()
    return ch
}

func main() {
    for v := range makeChan(context.Background(), []int{1, 2, 3}) {
        fmt.Println(v)
    } 
}

What did you expect to see?

Compilation successfully

What did you see instead?

Internal compiler error

.\main.go:19:19: internal compiler error: Type.Elem TYPEPARAM

goroutine 1 [running]:
runtime/debug.Stack()
	C:/dev/go/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0xf08d26d0, 0x213}, {0x12b4400, 0xc}, {0xc00011a5f0, 0x1, 0x1})
	C:/dev/go/src/cmd/compile/internal/base/print.go:227 +0x154
cmd/compile/internal/base.Fatalf(...)
	C:/dev/go/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/types.(*Type).Elem(0x48)
	C:/dev/go/src/cmd/compile/internal/types/type.go:989 +0x14d
cmd/compile/internal/noder.transformSend(0xc00064d4f0)
	C:/dev/go/src/cmd/compile/internal/noder/transform.go:502 +0x32
cmd/compile/internal/noder.(*irgen).stmt(0xc0000de0e0, {0x1413288, 0xc0000862a0})
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:44 +0x9b4
cmd/compile/internal/noder.(*irgen).stmts(0xc0000de0e0, {0xc00009e440, 0x2, 0x40})
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:19 +0xaf
cmd/compile/internal/noder.(*irgen).blockStmt(...)
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:205
cmd/compile/internal/noder.(*irgen).forStmt(0xc0000de0e0, 0xc00009a050)
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:240 +0x14f
cmd/compile/internal/noder.(*irgen).stmt(0xc0000de0e0, {0x1412f28, 0xc00009a050})
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:111 +0xaf1
cmd/compile/internal/noder.(*irgen).stmts(0xc0004930a0, {0xc00009e460, 0x2, 0x119b8b3})
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:19 +0xaf
cmd/compile/internal/noder.(*irgen).funcBody(0xc0000de0e0, 0xc000647b80, 0xc00064d1d0, 0xc0000a0200, 0xc0000a0240)
	C:/dev/go/src/cmd/compile/internal/noder/func.go:45 +0x25f
cmd/compile/internal/noder.(*irgen).funcLit(0xc0000de0e0, {0x1412140, 0xc000480d80}, 0xc00009e280)
	C:/dev/go/src/cmd/compile/internal/noder/expr.go:414 +0xe8
cmd/compile/internal/noder.(*irgen).expr0(0xc0000de0e0, {0x1412140, 0xc000480d80}, {0x1412f88, 0xc00009e280})
	C:/dev/go/src/cmd/compile/internal/noder/expr.go:110 +0x965
cmd/compile/internal/noder.(*irgen).expr(0xc0000de0e0, {0x1412f88, 0xc00009e280})
	C:/dev/go/src/cmd/compile/internal/noder/expr.go:81 +0x5ff
cmd/compile/internal/noder.(*irgen).expr0(0xc0000de0e0, {0x14121b8, 0x0}, {0x1412d78, 0xc0000a0400})
	C:/dev/go/src/cmd/compile/internal/noder/expr.go:116 +0x166
cmd/compile/internal/noder.(*irgen).expr(0xc0000de0e0, {0x1412d78, 0xc0000a0400})
	C:/dev/go/src/cmd/compile/internal/noder/expr.go:81 +0x5ff
cmd/compile/internal/noder.(*irgen).stmt(0xc0000de0e0, {0x1412da8, 0xc00009e260})
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:100 +0xa65
cmd/compile/internal/noder.(*irgen).stmts(0xc00064b960, {0xc0000a0440, 0x3, 0xc00060e498})
	C:/dev/go/src/cmd/compile/internal/noder/stmt.go:19 +0xaf
cmd/compile/internal/noder.(*irgen).funcBody(0xc0000de0e0, 0xc0000942c0, 0x114701d, 0xc0000a0100, 0xc0000a0140)
	C:/dev/go/src/cmd/compile/internal/noder/func.go:45 +0x25f
cmd/compile/internal/noder.(*irgen).funcDecl.func1()
	C:/dev/go/src/cmd/compile/internal/noder/decl.go:128 +0x68
cmd/compile/internal/noder.(*irgen).generate(0xc0000de0e0, {0xc00005eb90, 0x2, 0x20})
	C:/dev/go/src/cmd/compile/internal/noder/irgen.go:262 +0x1df
cmd/compile/internal/noder.check2({0xc00005eb90, 0x2, 0x2})
	C:/dev/go/src/cmd/compile/internal/noder/irgen.go:93 +0x175
cmd/compile/internal/noder.LoadPackage({0xc0001280f0, 0x2, 0x0})
	C:/dev/go/src/cmd/compile/internal/noder/noder.go:90 +0x335
cmd/compile/internal/gc.Main(0x12e1890)
	C:/dev/go/src/cmd/compile/internal/gc/main.go:190 +0xaf3
main.main()
	C:/dev/go/src/cmd/compile/main.go:55 +0xdd
@cuonglm cuonglm self-assigned this Sep 24, 2021
@cuonglm cuonglm added this to the Go1.18 milestone Sep 24, 2021
@gopherbot
Copy link

@gopherbot gopherbot commented Sep 24, 2021

Change https://golang.org/cl/351855 mentions this issue: cmd/compile: fix delayTransform condition

Loading

@gopherbot
Copy link

@gopherbot gopherbot commented Sep 24, 2021

Change https://golang.org/cl/351854 mentions this issue: cmd/compile: move all usage of delayTransform out of helpers.go

Loading

gopherbot pushed a commit that referenced this issue Sep 24, 2021
So next CL will make delayTransform to become irgen's method, because
the delay transform logic also depends on irgen.topFuncIsGeneric field.

For #48609

Change-Id: I660ed19856bd06c3b6f4279a9184db96175dea2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/351854
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
@gopherbot gopherbot closed this in cfd0868 Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants