From aa42d7b402ac163ebce141c2805eaf3558252606 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Mon, 30 Sep 2024 15:55:14 -0700 Subject: [PATCH] spec: clarify that identical structs must have identical field embeddings The existing prose for struct identity did only require that two structs "have the same sequence of fields, and if corresponding fields have the same names, and identical types, and identical tags" for the structs to be identical. The implementation (forever) has also required that two corresponding fields are either both embedded or not embedded. This is arguably part of a struct's structure but is not explicitly specified. This CL makes a minor change to the prose to address that. Fixes #69472. Change-Id: Ifa4ca69717986675642a09d03ce683ba8235efcb Reviewed-on: https://go-review.googlesource.com/c/go/+/616697 Reviewed-by: Rob Pike TryBot-Bypass: Robert Griesemer Reviewed-by: Ian Lance Taylor Reviewed-by: Robert Griesemer Auto-Submit: Robert Griesemer --- doc/go_spec.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 06aeeae658..50cb718395 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -1927,8 +1927,8 @@ components have identical types. In detail:
  • Two slice types are identical if they have identical element types.
  • Two struct types are identical if they have the same sequence of fields, - and if corresponding fields have the same names, and identical types, - and identical tags. + and if corresponding pairs of fields have the same names, identical types, + and identical tags, and are either both embedded or both not embedded. Non-exported field names from different packages are always different.
  • -- 2.48.1