]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: fix isStaticCompositeLiteral reports wrong for struct field
authorLE Manh Cuong <cuong.manhle.vn@gmail.com>
Wed, 1 May 2019 20:57:29 +0000 (03:57 +0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 3 May 2019 03:49:11 +0000 (03:49 +0000)
commit004fb5cb8dd74b9ac46a9990e9a028673b88e838
treed6a6a621fd5c07f34a232201a3e4924cb3880533
parent689ee112dfb872e97116acd4c8d96ece1533604e
cmd/compile: fix isStaticCompositeLiteral reports wrong for struct field

golang.org/cl/174498 add ONAME case to isStaticCompositeLiteral, to
detect global variable as compile-time constant.

It does report wrong for struct field, e.g:

o := one{i: two{i: 42}.i}

field i in two{i: 42} was reported as static composite literal, while it
should not.

In general, adding ONAME case for isStaticCompositeLiteral is probably
wrong.

Fixes #31782

Change-Id: Icde7d43bbb002b75df5c52b948b7126a4265e07b
Reviewed-on: https://go-review.googlesource.com/c/go/+/174837
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/cmd/compile/internal/gc/sinit.go
test/fixedbugs/issue31782.go [new file with mode: 0644]
test/fixedbugs/issue31782.out [new file with mode: 0644]