Releases: bufbuild/protocompile
v0.14.1
What's Changed
Bugfixes changes
- Fix bug where extension declarations marked as reserved would not allow the
full_name
ortype
fields to be specified. This failed to mirror the corresponding rule in the reference compilerprotoc
, which allows them to be set for documentation purposes. Now these two fields can be used on reserved declarations as long as both are present. By @jhump in #327 - Fix panic and error-reporting anomalies that can occur when interpreting options in lenient mode via calling either
options.InterpretOptionsLenient
oroptions.InterpretUnlinkedOptions
. By @jhump in #331
Full Changelog: v0.14.0...v0.14.1
v0.14.0
This version makes Protobuf Editions available to users of this package, without needing to use a special opt-in that is documented as test-only. It contains one backwards-incompatible change, only for users that used that Editions opt-in: it has been removed since the functionality is now generally available.
What's Changed
Bugfixes
- Correctly handle groups in the
TextName
method of field descriptors created by the compiler in #297 - Fix bug in extension declarations: presence of a declaration implies the range is verified in #303
- Fix a typo in code that adapts/re-parses features to match a descriptor; addresses a bug in
protoutil.ResolveCustomFeature
in #305 - Add more thorough checks for when to adapt a value when resolving custom feature; addresses a deficiency in
protoutil.ResolveCustomFeature
in #306 - Correctly handle maps in the
Kind
method of field descriptors created by the compiler, in files that define a file-wide default of delimited encoding for messages in #312
Enhancements
- Add
google/protobuf/cpp_features.proto
,google/protobuf/java_features.proto
, andgoogle/protobuf/go_features.proto
to the set of files provided byprotocomile.WithStandardImports
in #295 - Add some final checks to mirror logic of protoc v27.0: files cannot use custom features defined in the same file, enforce "feature support" options, which define the editions in which a feature and/or feature value can be used in #301 and #309
- Enable support for Protobuf Editions. To start, this only supports edition 2023. Added in #301
- This contains a backwards-incompatible change: the
editionstesting.AllowEditions()
function (which was documented as temporary when introduced in v0.10.0) has been removed.
- This contains a backwards-incompatible change: the
- Add
wellknownimports
package, for providing actual source code for the standard imports (wellknownimports.WithStandardImports
is an alternative toprotocompile.WithStandardImports
) in #310
Other changes
- Update linker tests to use
protodesc
to create descriptors from compilation results, to verify compilation results can be correctly processed by protobuf-go runtime in #302 - Add another (missing) test case for extension declarations in #304
Full Changelog: v0.13.0...v0.14.0
v0.13.0
v0.12.0
This release mostly contains performance improvements. It also includes an addition that makes it possible to implement a descriptor resolver on top of linker.Files
much more efficiently, using a *linker.Symbols
as an index.
What's Changed
Enhancements
- Add lookup methods to
*linker.Symbols
by @jhump in #286 - Various performance improvements (mostly reducing allocations) in the linker by @jhump in #286, #287, #290, and #291
Other changes
- Disallow options that use message-set-wire-format if Protobuf runtime can't support them by @jhump in #284
- Changes
ast.NoSourceNode
so that its methods now require a pointer receiver by @jhump in #291- This is a backwards-incompatible change. The impact should be low (likely even zero) since most users of this module will not be directly constructing
ast.NoSourceNode
values or type-assertingast.Node
values toast.NoSourceNode
. The change was made because of non-trivial performance gains, by greatly reducing the number ofNoSourceNode
values that need to be allocated on the heap when working with aparser.Result
that has no AST.
- This is a backwards-incompatible change. The impact should be low (likely even zero) since most users of this module will not be directly constructing
Full Changelog: v0.11.0...v0.12.0
v0.11.0
This release includes some more Editions-related work.
What's Changed
Bugfixes
- Validate target type for all option fields, not just features by @jhump in #279
- Previously, the
targets
field option was only validated for fields ofgoogle.protobuf.FeatureSet
, but it is now validated for all fields set on option values.
- Previously, the
- Fix issues with reporting of redundant/inaccurate errors by @jhump in #281
Enhancements
- Add Editions-related helper functions, for resolving features, to
protoutil
sub-package by @jhump in #283 - Allow access to original descriptor when wrapped in a
linker.File
via newUnwrap
method by @jhump in #278
Other changes
- Proto2 group fields can use lower-case name in the text format (in option values that use message literals) by @jhump in #268
- This aligns protocompile with a small change that is coming in protoc v27.0.
Full Changelog: v0.10.0...v0.11.0
v0.10.0
This release marks significant progress in implementing Protobuf Editions. Editions are not yet generally supported because there are a couple of remaining checks that need to be done. Until then, users can opt-in to using Editions source files with this compiler using the editionstesting.AllowEditions
function.
This release also includes some backwards-incompatible changes, though they likely will not have any impact on most users. They are changes to interfaces that are compatible for users/callers of the interface, but incompatible for any code outside of this repo that implemented those interfaces.
What's Changed
Bugfixes
- In the recently added
options.StripSourceRetentionOptionsFromFile
, clear options if no fields remain and also clear source code info, in #251 - This repo previously allowed some sources that
protoc
would reject, due to incomplete validation of options. These checks were added in #264:- Non-lite files may not import lite files. (A lite file is one that uses option
optimize_for=LITE_RUNTIME
.) - Extensions in a lite file may not extend messages in a non-lite file.
- Field options
lazy
andunverified_lazy
can only be set to true for message fields. - Field option
jstype
can only be customized for 64-bit integer fields (int64
,uint64
,sint64
,fixed64
, andsfixed64
).
- Non-lite files may not import lite files. (A lite file is one that uses option
Enhancements
- Editions-related updated:
- Update descriptor implementations to work with Editions files, in #260, #261, and #270
- Add more internal compiler support for Editions, in #264
- Provide an exported function for users to opt-in to using Editions, in #267. Note that this capability is temporary and will be removed once Editions support is complete (since opt-in won't be necessary and Editions support will be generally available).
- Support and enforce extension declarations, in #263
Other Changes
- Remove feature related to "canonical bytes", in #261
- This is a backwards-incompatible change, but only impacts a likely-unused feature. The method
linker.Result.CanonicalProto()
has been removed. This feature was too complicated to continue supporting in the face of changes to interpreting options that needed to be implemented for Editions. (The feature was ultimately never used for its original intended purpose, so is likely not used at all.)
- This is a backwards-incompatible change, but only impacts a likely-unused feature. The method
- Add support for iterating option nodes in the
ast
sub-package via newast.NodeWithOptions
interface, in #263- This is a backwards-incompatible change, but only impacts code that implements some of this repo's interfaces, not any code that merely uses those interfaces.
- This adds a new
RangeOptions
function to several sub-interfaces ofast.Node
, so they also are now sub-interfaces ofast.NodeWtihOptions
. The interfaces changed areast.FileDeclNode
,ast.MessageDeclNode
,ast.FieldDeclNode
,ast.OneofDeclNode
,ast.RPCDeclNode
, andast.EnumValueDeclNode
. - This also adds a method,
ExtensionsNode
, to theparser.Result
interface, and expands the return types of three methods (OneofNode
,EnumNode
, andServiceNode
) fromast.Node
toast.NodeWithOptions
.
Full Changelog: v0.9.0...v0.10.0
v0.9.0
This release contains a minor change and one new exported function.
Improvements:
- The experimental
github.com/bufbuild/protocompile/parser/fastscan
package has been updated so it's even faster: it can scan in roughly half the time using a fourth as much memory as the previous version.
Additions:
- A new
options.StripSourceRetentionOptionsFromFile
helper function has been added, for use by tools that use the results of this compiler to do code generation. This function accepts a file descriptor and returns a modified version of it that has all options marked as "source" retention removed.
v0.8.0
This release primarily fixes bugs in the compiler that resulted in differences between the source files that protocompile would accept vs. the source files that the reference compiler, protoc
, would accept. But one of these changes resulted in an unused AST node type. So this type has been removed from the exported API, which is why this v0.8.0 instead of v0.7.2.
Fixes:
- A
protocompile.Compiler
would previously accept some sources that would be rejected byprotoc
. In particular,protocompile
allowed for explicitly-signed positive numeric literals -- with a leading plus (+) sign. But this is not allowed by the reference compiler,protoc
, nor by implementations of the text format in myriad languages (which is also the format the compiler uses to parse custom option values that are message literals).- This change is not backwards compatible. The AST node type
ast.PositiveUintLiteralNode
has been removed. It was only used to support this invalid construct in the language. Code that refers to this node type (or its associated factory function andVisitor
method) must be removed.
- This change is not backwards compatible. The AST node type
- A
protocompile.Compiler
would previously reject some sources that wouldprotoc
would accept. In particular,protocompile
did not allow-nan
as a default field value or custom option value and it also did not acceptinf
and alternate case spellings (such as upper- or mixed-case) ofinfinity
andnan
in message literals, which are all allowed byprotoc
.
v0.7.1
Fixes:
- If a
protocompile.Compiler
'sResolver
returns a*descriptorpb.FileDescriptorProto
(instead of source code or an already-builtprotoreflect.FileDescriptor
), any already-interpreted options therein would be inadvertently cleared when the compiler reached the step of interpreting options for that file. This has been fixed: descriptor protos with options already interpreted will be left alone.
v0.7.0
This release contains some potentially breaking changes. Such changes were deemed acceptable since this module has not yet reached v1.0 and the impact on existing user code is likely to be very low.
Fixes:
- Previously,
protocompile
would allow thepacked
field option to be used on non-repeated fields are repeated fields that cannot be packed (like repeated string, bytes, and message fields). Such sources would be rejected by the reference compiler,protoc
, and the resulting descriptors would be rejected by some Protobuf runtime libraries (including the one for Go). This has been fixed. Soprotocompile
now also rejects such incorrect sources. - A panic could occur in the parser with certain kinds of malformed input that contained syntactically incorrect message literals in option values. This has been fixed, and such sources now result in a syntax error value instead of a panic.
Changes:
- The
ErrorWithPos
interface has two new methods,Start() ast.SourcePos
andEnd() ast.SourcePos
. This change allows errors to indicate an entire region of code, not just a single position.- This is a breaking change. It is expected that this interface was only implemented internally. If there are implementations outside of this repo, fixing them can be as straight-forward as implementing the two new methods to return the same position as the existing
GetPosition()
method.
- This is a breaking change. It is expected that this interface was only implemented internally. If there are implementations outside of this repo, fixing them can be as straight-forward as implementing the two new methods to return the same position as the existing
- The various helper functions for creating
ErrorWithPos
instances now accept anast.SourceSpan
instead of anast.SourcePos
. This includesreporter.Error
andreporter.Errorf
as well as the methodsHandleErrorWithPos
,HandleErrorf
,HandleWarningWithPos
, andHandleWarningf
ofreporter.Handler
.- This is a breaking change. It is expected that these functions, despite being exported, were only used internally by the compiler implementation. If there are existing calls outside of this repo and a span (such as a
ast.NodeInfo
,ast.ItemInfo
, orast.Comment
) is not readily available to them, they can useast.NewSourceSpan
to construct a span whose start and end are the sameast.SourcePos
and pass that.
- This is a breaking change. It is expected that these functions, despite being exported, were only used internally by the compiler implementation. If there are existing calls outside of this repo and a span (such as a
Additions:
- A new
ast.SourceSpan
interface type has been added that represents a span of code. There are also two factory functions for creating instances ofast.SourceSpan
:ast.NewSourceSpan
andast.UnknownSpan
. This interface is implemented by existing typesast.NodeInfo
,ast.ItemInfo
,ast.Comment
, andreporter.ErrorWithPos
. - A new
github.com/bufbuild/protocompile/parser/fastscan
package has been added. While this entire repo is pre-v1.0, and therefore may be subject to incompatible changes (as evidenced by the backwards-incompatible change in this release), this new package is considered experimental. So the threshold for allowing an incompatible change to this package is even lower, and its API should be viewed as less stable.