// expected: cannot use value of type []*main.T as []main.T // // The header names stage4's wording; legacy rejects the same fixture through // go/types with its own phrasing ("cannot use xs (variable of type []*T) as // []T value in assignment"), which is why this fixture is checked by the // restriction suite that runs stage4. // // A store into a struct FIELD, a slice element, a map value and a // through-a-pointer target is an assignment and must be type-checked like one. // stage4 checked only a store into a plain variable, so this compiled and // stored a pointer array where an array of struct values was declared. Reading // it back is not a diagnostic, it is silent garbage: smesh's // nostr.NewTags(list ...*Tag) assigned []*Tag to `List []Tag` and the marmot // codec test died with SIGBUS on the first field read. Legacy rejected it all // along (go/types: "cannot use xs (variable of type []*T) as []T value in // assignment"), so this was also a compilers-disagree bug. package main type T struct { n int32 } type Holder struct { List []T } func build(xs []*T) (h *Holder) { h = &Holder{} h.List = xs return h } func main() { a := &T{n: 1} h := build([]*T{a}) println(len(h.List)) }