]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix maplit init panics for dynamic entry
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>
Wed, 1 May 2019 14:57:52 +0000 (21:57 +0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 1 May 2019 21:14:28 +0000 (21:14 +0000)
commitaaf40f8f98ded15d0a039470a552f58b8b71abac
tree650764f140aa2d2ac14f5c65d9edacfcb994d5ae
parent40a6d0e0ef0fd2020423dd9c35b0fb62d2cb016e
cmd/compile: fix maplit init panics for dynamic entry

golang.org/cl/174498 removes dynamic map entry handling in maplit, by
filtering the static entry only. It panics if it see a dynamic entry.
It relies on order to remove all dynamic entries.

But after recursively call order on the statics, some static entries
become dynamic, e.g OCONVIFACE node:

type i interface {
j()
}
type s struct{}

func (s) j() {}

type foo map[string]i

var f = foo{
"1": s{},
}

To fix it, we recursively call order on each static entry, if it changed
to dynamic, put entry to dynamic then.

Fixes #31777

Change-Id: I1004190ac8f2d1eaa4beb6beab989db74099b025
Reviewed-on: https://go-review.googlesource.com/c/go/+/174777
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/order.go
test/fixedbugs/issue31777.go [new file with mode: 0644]