The proposal design docs (https://go.googlesource.com/proposal/+/refs/heads/master/design/43651-type-parameters.md) mentions:
// structField is a type constraint whose type set consists of some // struct types that all have a field named x. type structField interface { struct { a int; x int } | struct { b int; x float64 } | struct { c int; x uint64 } } // This function is INVALID. func IncrementX[T structField](p *T) { v := p.x // INVALID: type of p.x is not the same for all types in set v++ p.x = v } However, it still fails to compile if all the types of the x fields are identical. type structField interface { struct { a int; x int } | struct { b int; x int } | struct { c int; x int } } func IncrementX[T structField](p *T) { v := p.x // p.x undefined (type *T has no field or method x) v++ p.x = v // p.x undefined (type *T has no field or method x) } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/451c441a-d4c1-48e5-aa1a-01118bd32f1en%40googlegroups.com.