mirror of
https://github.com/golang/go
synced 2024-11-14 17:20:21 -07:00
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 <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>
This commit is contained in:
parent
8c52cd3da5
commit
aa42d7b402
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user