Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cmd/compile: build panic if there are same name Type and TypeAlias #31959

Closed
micln opened this issue May 10, 2019 · 6 comments
Closed

cmd/compile: build panic if there are same name Type and TypeAlias #31959

micln opened this issue May 10, 2019 · 6 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@micln
Copy link

micln commented May 10, 2019

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

$ go version
go version go1.12.5 darwin/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
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/me/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/me/Codes/go/go0:/Users/me/Codes/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.5/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4w/w1flty7116z_rxq67hdjvl5r0000gp/T/go-build927971832=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Give a type named "A" and a type alias named "A" in a function,
then import this package in other place

What did you expect to see?

go build success or failed with redefined message

What did you see instead?

go build panic

test/duplicate_type/main

runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0x1a556a1, 0xe)
/usr/local/Cellar/go/1.12.5/libexec/src/runtime/panic.go:617 +0x72
runtime.newstack()
/usr/local/Cellar/go/1.12.5/libexec/src/runtime/stack.go:1041 +0x6f0
runtime.morestack()
/usr/local/Cellar/go/1.12.5/libexec/src/runtime/asm_amd64.s:429 +0x8f

goroutine 1 [running]:
encoding/binary.ReadUvarint(0x1c01a80, 0xc00177a040, 0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.12.5/libexec/src/encoding/binary/varint.go:106 +0x12d fp=0xc024000360 sp=0xc024000358 pc=0x10ef33d
cmd/compile/internal/gc.(*importReader).uint64(0xc00177a040, 0xc00177a040)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:647 +0x3b fp=0xc0240003b0 sp=0xc024000360 pc=0x183162b
cmd/compile/internal/gc.(*importReader).string(0xc00177a040, 0x0, 0xc024000440)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:261 +0x2b fp=0xc0240003e0 sp=0xc0240003b0 pc=0x182e9ab
cmd/compile/internal/gc.(*importReader).qualifiedIdent(0xc00177a040, 0x0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:455 +0x2f fp=0xc024000450 sp=0xc0240003e0 pc=0x182fcef
cmd/compile/internal/gc.(*importReader).typ1(0xc00177a040, 0xc00177a040)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:513 +0xa40 fp=0xc0240005b8 sp=0xc024000450 pc=0x1830fd0
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024000608 sp=0xc0240005b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc00177a000, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024000630 sp=0xc024000608 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc00177a000, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024000700 sp=0xc024000630 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024000750 sp=0xc024000700 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779fc0, 0xc001779fc0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240008b8 sp=0xc024000750 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024000908 sp=0xc0240008b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779f80, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024000930 sp=0xc024000908 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779f80, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024000a00 sp=0xc024000930 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024000a50 sp=0xc024000a00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779f40, 0xc001779f40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024000bb8 sp=0xc024000a50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024000c08 sp=0xc024000bb8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779f00, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024000c30 sp=0xc024000c08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779f00, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024000d00 sp=0xc024000c30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024000d50 sp=0xc024000d00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779ec0, 0xc001779ec0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024000eb8 sp=0xc024000d50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024000f08 sp=0xc024000eb8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779e80, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024000f30 sp=0xc024000f08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779e80, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024001000 sp=0xc024000f30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024001050 sp=0xc024001000 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779e40, 0xc001779e40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240011b8 sp=0xc024001050 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024001208 sp=0xc0240011b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779e00, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024001230 sp=0xc024001208 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779e00, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024001300 sp=0xc024001230 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024001350 sp=0xc024001300 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779dc0, 0xc001779dc0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240014b8 sp=0xc024001350 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024001508 sp=0xc0240014b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779d80, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024001530 sp=0xc024001508 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779d80, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024001600 sp=0xc024001530 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024001650 sp=0xc024001600 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779d40, 0xc001779d40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240017b8 sp=0xc024001650 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024001808 sp=0xc0240017b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779d00, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024001830 sp=0xc024001808 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779d00, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024001900 sp=0xc024001830 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024001950 sp=0xc024001900 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779cc0, 0xc001779cc0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024001ab8 sp=0xc024001950 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024001b08 sp=0xc024001ab8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779c80, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024001b30 sp=0xc024001b08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779c80, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024001c00 sp=0xc024001b30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024001c50 sp=0xc024001c00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779c40, 0xc001779c40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024001db8 sp=0xc024001c50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024001e08 sp=0xc024001db8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779c00, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024001e30 sp=0xc024001e08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779c00, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024001f00 sp=0xc024001e30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024001f50 sp=0xc024001f00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779bc0, 0xc001779bc0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240020b8 sp=0xc024001f50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024002108 sp=0xc0240020b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779b80, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024002130 sp=0xc024002108 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779b80, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024002200 sp=0xc024002130 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024002250 sp=0xc024002200 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779b40, 0xc001779b40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240023b8 sp=0xc024002250 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024002408 sp=0xc0240023b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779b00, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024002430 sp=0xc024002408 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779b00, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024002500 sp=0xc024002430 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024002550 sp=0xc024002500 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779ac0, 0xc001779ac0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240026b8 sp=0xc024002550 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024002708 sp=0xc0240026b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779a80, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024002730 sp=0xc024002708 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779a80, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024002800 sp=0xc024002730 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024002850 sp=0xc024002800 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779a40, 0xc001779a40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240029b8 sp=0xc024002850 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024002a08 sp=0xc0240029b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779a00, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024002a30 sp=0xc024002a08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779a00, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024002b00 sp=0xc024002a30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024002b50 sp=0xc024002b00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc0017799c0, 0xc0017799c0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024002cb8 sp=0xc024002b50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024002d08 sp=0xc024002cb8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779980, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024002d30 sp=0xc024002d08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779980, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024002e00 sp=0xc024002d30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024002e50 sp=0xc024002e00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779940, 0xc001779940)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024002fb8 sp=0xc024002e50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024003008 sp=0xc024002fb8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779900, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024003030 sp=0xc024003008 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779900, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024003100 sp=0xc024003030 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024003150 sp=0xc024003100 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc0017798c0, 0xc0017798c0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240032b8 sp=0xc024003150 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024003308 sp=0xc0240032b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779880, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024003330 sp=0xc024003308 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779880, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024003400 sp=0xc024003330 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024003450 sp=0xc024003400 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779840, 0xc001779840)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240035b8 sp=0xc024003450 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024003608 sp=0xc0240035b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779800, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024003630 sp=0xc024003608 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779800, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024003700 sp=0xc024003630 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024003750 sp=0xc024003700 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc0017797c0, 0xc0017797c0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc0240038b8 sp=0xc024003750 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024003908 sp=0xc0240038b8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779780, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024003930 sp=0xc024003908 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779780, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024003a00 sp=0xc024003930 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024003a50 sp=0xc024003a00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc001779740, 0xc001779740)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024003bb8 sp=0xc024003a50 pc=0x18310dc
cmd/compile/internal/gc.(*iimporter).typAt(0xc00038a0c0, 0x20, 0xc000094640)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:494 +0xff fp=0xc024003c08 sp=0xc024003bb8 pc=0x183047f
cmd/compile/internal/gc.(*importReader).typ(0xc001779700, 0x300000000004)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:485 +0x3d fp=0xc024003c30 sp=0xc024003c08 pc=0x183035d
cmd/compile/internal/gc.(*importReader).doDecl(0xc001779700, 0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:279 +0x79c fp=0xc024003d00 sp=0xc024003c30 pc=0x182f24c
cmd/compile/internal/gc.expandDecl(0xc00039cb40)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:49 +0x83 fp=0xc024003d50 sp=0xc024003d00 pc=0x182ce63
cmd/compile/internal/gc.(*importReader).typ1(0xc0017796c0, 0xc0017796c0)
/usr/local/Cellar/go/1.12.5/libexec/src/cmd/compile/internal/gc/iimport.go:515 +0xb4c fp=0xc024003eb8 sp=0xc024003d50 pc=0x18310dc
...additional frames elided...

some useful info for yours

package a

type A struct{}

func B() {
	type A = map[string]map[string]interface{}
}
package main

import (
	"fmt"

	. "a"
)

func main() {
	fmt.Println(A{})
}

cases don't panic and can build success:

  • change type A = xx to type A xx will build success
  • move all codes to package main will build success

thanks~

@beoran
Copy link

beoran commented May 10, 2019

This looks like a compiler error because it does compile like this:

https://play.golang.org/p/Jfrn1JdRnGG

package main
import "fmt"

type A struct{}

func B() {
	type A = map[string]map[string]interface{}
	fmt.Println(A{})
}

func main() {
	fmt.Println(A{})
	B()
}

The alias in the function correctly shadows the top level struct but only inside the function.

@micln
Copy link
Author

micln commented May 10, 2019

@beoran

I can run this code successful

so I append two cases which correctly in the end of issues

@josharian
Copy link
Contributor

@mdempsky

@andybons andybons changed the title go build panic if there are same name Type and TypeAlias cmd/compile: build panic if there are same name Type and TypeAlias May 13, 2019
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 13, 2019
@andybons andybons added this to the Unplanned milestone May 13, 2019
@cuonglm
Copy link
Member

cuonglm commented May 15, 2019

The problem is type alias typecheck always replace the original definition of the symbol, so the symbol is written to compiled file as alias, instead of original type.

When a file import this compiled file, the import reader see the original type at line 3, but with wrong symbol metadata (which is alias), causing infinite loop to detect the right type for symbol, the compiler goes boom.

I'm sending a CL to fix it.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/177378 mentions this issue: cmd/compile: fix typecheck type makes wrong export symbol metadata

@micln
Copy link
Author

micln commented May 24, 2019

thanks all !

@golang golang locked and limited conversation to collaborators May 23, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants