Skip to content

editions: compiler disallows extension to have default value when file sets default presence to implicit #16664

@jhump

Description

@jhump

Extensions always have explicit presence. If an attempt is made to set the field_presence feature to IMPLICIT, the result is an error: "Extensions can't specify field presence".

Unfortunately, if the file default is set to IMPLICIT, protoc is acting as if the extension's field presence inherits this and does not allow setting a default value.

// test.proto
edition = "2023";
option features.field_presence = IMPLICIT;
message Extendee {
  extensions 1 to 2;
}
extend Extendee {
  uint32 ext_with_default = 1 [default = 123];
}
test.proto:8:10: Implicit presence fields can't specify defaults.

Metadata

Metadata

Labels

untriagedauto added to all issues by default when created.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions