1 // Pushing an untyped nil as the element of a slice of slices. The element
2 // conversion nil -> []T is a zero value of an AGGREGATE type, and the IR for it
3 // was spelled `null` (the pointer zero) instead of `zeroinitializer`, which
4 // clang rejects: "null must be a pointer type". Seen in text/tabwriter
5 // (`b.lines = push(b.lines, nil)`).
6 package main
7 8 type cell struct {
9 b []byte
10 }
11 12 func main() {
13 // Termination: a batch program must still be stoppable, so the entry
14 // handles the channel the runtime closes on SIGINT/SIGTERM.
15 select {
16 case <-shutdown:
17 return
18 default:
19 }
20 21 lines := [][]cell{:1}
22 lines = lines[:0]
23 lines = push(lines, nil)
24 if len(lines) != 1 {
25 panic("expected one line")
26 }
27 if len(lines[0]) != 0 {
28 panic("expected an empty line")
29 }
30 lines[0] = push(lines[0], cell{b: []byte("x")})
31 if len(lines[0]) != 1 {
32 panic("expected one cell")
33 }
34 }
35 36