Skip to content

cmd/compile: internal compiler error: cannot export DYNAMICDOTTYPE (154) node #49027

@aadog

Description

@aadog

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

$ go version

go version devel go1.18-cf51fb5d68 Sun Oct 17 04:27:13 2021 +0000 windows/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
C:\Users\pouk\go\src\awesomeProject>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\pouk\AppData\Local\go-build
set GOENV=C:\Users\pouk\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\pouk\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\pouk\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\pouk\.go\current
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Users\pouk\.go\current\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=devel go1.18-cf51fb5d68 Sun Oct 17 04:27:13 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\pouk\go\src\awesomeProject\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\pouk\AppData\Local\Temp\go-build4143047649=/tmp/go-build -gno-record-gcc-switches

What did you do?

package main

import (
	"fmt"
)

func Check2ToString1(v interface{}) string {
	return CheckTo[string](v)
}
func CheckTo[T any](v interface{}) T {
	var o T
	if v == nil {
		return o
	}
	return v.(T)
}
func main() {
	fmt.Println(Check2ToString1("11"))
}

What did you expect to see?

11

What did you see instead?

# awesomeProject
.\main.go:15:2: internal compiler error: cannot export DYNAMICDOTTYPE (154) node
	==> please file an issue and assign to gri@

goroutine 1 [running]:
runtime/debug.Stack()
	C:/Users/pouk/.go/gotip/src/runtime/debug/stack.go:24 +0x65
cmd/compile/internal/base.FatalfAt({0x18086a8, 0x0}, {0x16cd174, 0x47}, {0xc0000cd5e0, 0x2, 0x2})
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/base/print.go:227 +0x1ca
cmd/compile/internal/base.Fatalf(...)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/base/print.go:196
cmd/compile/internal/typecheck.(*exportWriter).expr(0xc00063b260, {0x18086a8, 0xc0005e0060})
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:2132 +0x1aff
cmd/compile/internal/typecheck.(*exportWriter).exprList(0xc00063b260, {0xc0005d20f0, 0x1, 0xc000430fc0})
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:1681 +0x76
cmd/compile/internal/typecheck.(*exportWriter).stmt(0xc00063b260, {0x1809a30, 0xc0005dc0f0})
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:1574 +0x91f
cmd/compile/internal/typecheck.(*exportWriter).node(0xc00060bc50, {0x1809a30, 0xc0005dc0f0})
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:1483 +0x65
cmd/compile/internal/typecheck.(*exportWriter).stmtList(0xc00063b260, {0xc0005d0040, 0x4, 0x16760c0})
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:1476 +0x76
cmd/compile/internal/typecheck.(*exportWriter).funcBody(0xc00063b260, 0xc00006e840)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:1471 +0x5b
cmd/compile/internal/typecheck.(*iexporter).doInline(0xc000638370, 0xc000428f70)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:662 +0xc5
cmd/compile/internal/typecheck.(*exportWriter).funcExt(0xc00063b1f0, 0xc000428f70)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:1408 +0x1b6
cmd/compile/internal/typecheck.(*iexporter).doDecl(0xc000638370, 0xc000428f70)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:533 +0x21e
cmd/compile/internal/typecheck.WriteExports({0x1802640, 0xc00060ba40}, 0x1)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/typecheck/iexport.go:331 +0x2e5
cmd/compile/internal/noder.WriteExports(0xc00062a600)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/noder/export.go:40 +0x7a
cmd/compile/internal/gc.dumpCompilerObj(0xc00062a600)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/gc/obj.go:107 +0x28
cmd/compile/internal/gc.dumpobj1({0xc0000c4100, 0x3f}, 0x3)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/gc/obj.go:63 +0x17b
cmd/compile/internal/gc.dumpobj()
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/gc/obj.go:44 +0x36
cmd/compile/internal/gc.Main(0x16d4b50)
	C:/Users/pouk/.go/gotip/src/cmd/compile/internal/gc/main.go:334 +0x1136
main.main()
	C:/Users/pouk/.go/gotip/src/cmd/compile/main.go:55 +0xdd


Compilation finished with exit code 2

If you have the code below then it will run normally,I do not know why----------------------------》

package main

import (
	"fmt"
	"reflect"
)

func Check2ToString1(v interface{}) string {
	return CheckTo[string](v)
}
func CheckTo[T any](v interface{}) T {
	var o T
	if v == nil {
		return o
	}
	iv := reflect.ValueOf(v)
	_ = iv
	return v.(T)
}
func main() {
	fmt.Println(Check2ToString1("11"))
}

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