]> Cypherpunks repositories - gostls13.git/commitdiff
spec: clarify that identical structs must have identical field embeddings
authorRobert Griesemer <gri@golang.org>
Mon, 30 Sep 2024 22:55:14 +0000 (15:55 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 2 Oct 2024 00:57:58 +0000 (00:57 +0000)
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 <r@golang.org>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

doc/go_spec.html

index 06aeeae6582b56ea534e11a0da6896949500b015..50cb718395d94d65702543b51f0c4df63ddbc0de 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Language version go1.23 (Aug 12, 2024)",
+       "Subtitle": "Language version go1.23 (Oct 1, 2024)",
        "Path": "/ref/spec"
 }-->
 
@@ -1927,8 +1927,8 @@ components have identical types. In detail:
        <li>Two slice types are identical if they have identical element types.</li>
 
        <li>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.
            <a href="#Exported_identifiers">Non-exported</a> field names from different
            packages are always different.</li>