| 1 | // Copyright 2026 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | //go:build go1.27 |
| 6 | |
| 7 | package main |
| 8 | |
| 9 | func main() { |
| 10 | // Test direct initialization of promoted fields in struct literals, |
| 11 | // introduced in go1.27. See golang/go#9859. |
| 12 | type Inner struct { |
| 13 | X int |
| 14 | } |
| 15 | type Outer struct { |
| 16 | Inner |
| 17 | Y int |
| 18 | } |
| 19 | |
| 20 | o := Outer{ |
| 21 | X: 1, |
| 22 | Y: 2, |
| 23 | } |
| 24 | |
| 25 | if o.X != 1 || o.Y != 2 { |
| 26 | panic("failed to initialize promoted field") |
| 27 | } |
| 28 | } |