Skip to content

Commit cb88647

Browse files
committed
all: add EDITION_UNSTABLE support
The UNSTABLE edition serves as a sandbox for all features in-development. The --experimental_edition protoc flag is required to accept it. Google-Internally, see go/edition-unstable for more details. Originally authored by Rachel Goldfinger, who asked me to send the change. Change-Id: If3acc284f70b7690e837d4746202823880a13355 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/727960 Reviewed-by: Lasse Folger <lassefolger@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
1 parent aeaf00b commit cb88647

3 files changed

Lines changed: 5 additions & 2 deletions

File tree

internal/filedesc/desc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const (
3232
EditionProto3 Edition = 999
3333
Edition2023 Edition = 1000
3434
Edition2024 Edition = 1001
35+
EditionUnstable Edition = 9999
3536
EditionUnsupported Edition = 100000
3637
)
3738

reflect/protodesc/desc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ func (o FileOptions) New(fd *descriptorpb.FileDescriptorProto, r Resolver) (prot
108108
if f.L1.Path == "" {
109109
return nil, errors.New("file path must be populated")
110110
}
111-
if f.L1.Syntax == protoreflect.Editions && (fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) {
111+
if f.L1.Syntax == protoreflect.Editions &&
112+
(fd.GetEdition() < editionssupport.Minimum || fd.GetEdition() > editionssupport.Maximum) &&
113+
fd.GetEdition() != descriptorpb.Edition_EDITION_UNSTABLE {
112114
// Allow cmd/protoc-gen-go/testdata to use any edition for easier
113115
// testing of upcoming edition features.
114116
if !strings.HasPrefix(fd.GetName(), "cmd/protoc-gen-go/testdata/") {

reflect/protodesc/editions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func getFeatureSetFor(ed filedesc.Edition) *descriptorpb.FeatureSet {
5858
return def
5959
}
6060
edpb := toEditionProto(ed)
61-
if defaults.GetMinimumEdition() > edpb || defaults.GetMaximumEdition() < edpb {
61+
if (defaults.GetMinimumEdition() > edpb || defaults.GetMaximumEdition() < edpb) && edpb != descriptorpb.Edition_EDITION_UNSTABLE {
6262
// This should never happen protodesc.(FileOptions).New would fail when
6363
// initializing the file descriptor.
6464
// This most likely means the embedded defaults were not updated.

0 commit comments

Comments
 (0)