mirror of
https://github.com/golang/go
synced 2024-09-04 23:44:16 +00:00
![Cuong Manh Le](/assets/img/avatar_default.png)
CL 230121 fixed the bug that struct literal blank fields type array/struct can not be initialized. But it still misses some cases when an expression causes "candiscard(value)" return false. When these happen, we recursively call fixedlit with "var_" set to "_", and hit the bug again. To fix it, just making splitnode return "nblank" whenever "var_" is "nblank". Fixes #38905 Change-Id: I281941b388acbd551a4d8ca1a235477f8d26fb6e Reviewed-on: https://go-review.googlesource.com/c/go/+/232617 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
19 lines
509 B
Go
19 lines
509 B
Go
// compile
|
|
|
|
// Copyright 2020 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.
|
|
|
|
// Make sure that literal value can be passed to struct
|
|
// blank field with expressions where candiscard(value)
|
|
// returns false, see #38905.
|
|
|
|
package p
|
|
|
|
type t struct{ _ u }
|
|
type u [10]struct{ f int }
|
|
|
|
func f(x int) t { return t{u{{1 / x}, {1 % x}}} }
|
|
func g(p *int) t { return t{u{{*p}}} }
|
|
func h(s []int) t { return t{u{{s[0]}}} }
|