mirror of
https://github.com/golang/go
synced 2024-11-14 15:00:27 -07:00
004fb5cb8d
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>
25 lines
399 B
Go
25 lines
399 B
Go
// run
|
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Check static composite literal reports wrong for struct
|
|
// field.
|
|
|
|
package main
|
|
|
|
type one struct {
|
|
i interface{}
|
|
}
|
|
|
|
type two struct {
|
|
i interface{}
|
|
s []string
|
|
}
|
|
|
|
func main() {
|
|
o := one{i: two{i: 42}.i}
|
|
println(o.i.(int))
|
|
}
|