| 1 |
// compile |
| 2 |
|
| 3 |
// Copyright 2026 The Go Authors. All rights reserved. |
| 4 |
// Use of this source code is governed by a BSD-style |
| 5 |
// license that can be found in the LICENSE file. |
| 6 |
|
| 7 |
// Issue 77534: compiler crash when >4 fields, but only one nonempty pointer field. |
| 8 |
|
| 9 |
package p |
| 10 |
|
| 11 |
type T struct { |
| 12 |
a, b, c, d struct{} |
| 13 |
e *byte |
| 14 |
} |
| 15 |
|
| 16 |
func f1(p *any, t T) { |
| 17 |
*p = t |
| 18 |
} |
| 19 |
|
| 20 |
func f2(p *any, t *T) { |
| 21 |
*p = *t |
| 22 |
} |
| 23 |
|
| 24 |
func f3(p, x, y *T, b bool) { |
| 25 |
var z T |
| 26 |
if b { |
| 27 |
z = *x |
| 28 |
} else { |
| 29 |
z = *y |
| 30 |
} |
| 31 |
*p = z |
| 32 |
} |
| 33 |
|
| 34 |
func f4(i any) T { |
| 35 |
return i.(T) |
| 36 |
} |
| 37 |
|
| 38 |
type Inner struct { |
| 39 |
a struct{} |
| 40 |
p *byte |
| 41 |
} |
| 42 |
|
| 43 |
type Outer struct { |
| 44 |
inner Inner |
| 45 |
} |
| 46 |
|
| 47 |
func f5(o1, o2 Outer, c bool) Outer { |
| 48 |
var i any |
| 49 |
if c { |
| 50 |
i = o1 |
| 51 |
} else { |
| 52 |
i = o2 |
| 53 |
} |
| 54 |
return i.(Outer) |
| 55 |
} |