Releases: bufbuild/protocompile
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.
v0.6.0
This release contains several 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:
- If a
protocompile.Resolver
returns search results that include descriptor protos, the compilation step that interprets options could inexplicably fail. This was because the logic was relying on an AST for some metadata about the option declarations in the source. This has been fixed: if a descriptor proto is provided that contains uninterpreted options, they can now be successfully interpreted.
Changes:
- Numerous elements have been renamed so that references to "oneof" elements now use the spelling "Oneof" instead of "OneOf" (second "O" now lower-case). This is for consistency with how this is spelled in the core protobuf runtime, in the "google.golang.org/protobuf" module).
- This is a breaking change. Fixes to user code that may have been broken by this change should be straight-forward and mechanical.
- The grammar used to generate the parser has been improved. In particular, all conflicts in the yacc configuration have been eliminated. This does not fix any known bug, but it does provide higher confidence that no latent bugs exist since the generated parser could previously have chosen the wrong action in the face of a conflict.
- The function
sourceinfo.GenerateSourceInfo
now accepts asourceinfo.OptionIndex
instead of anoptions.Index
. It also now accepts variadic options. The functionsourceinfo.GenerateSourceInfoWithExtraComments
has been removed; its functionality can now be accomplished by passing an option tosourceinfo.GenerateSourceInfo
.- This is a breaking change. It is expected that these functions, despite being exported, were only used internally by the compiler implementation.
- The type
options.Index
has been removed. Code should instead use the newsourceinfo.OptionIndex
type.- This is a breaking change. It is expected that this type, despite being exported, was only used internally by the compiler implementation.
Additions:
- A new
protocompile.SourceInfoMode
value has been added:SourceInfoExtraOptionLocations
. This can be combined with other values (via bitwise OR) to have the compiler include additional source code info for locations inside message literals in custom option values. - A new
sourceinfo.OptionIndex
type has been added, along with related types in the same package:OptionSourceInfo
,OptionChildrenSourceInfo
,ArrayLiteralSourceInfo
, andMessageLiteralSourceInfo
. These provide a model of source info paths in the interior of an option declaration. - A new
sourceinfo.GenerateOption
type has been added, allowing the behavior ofsourceinfo.GenerateSourceInfo
to be customized via variadic options. Options are available for retaining extra comments (sourceinfo.WithExtraComments
) and for producing extra locations for option declarations with message literal values (sourceinfo.WithExtraOptionLocations
).
v0.5.1
This is an urgent bug-fix release, to remedy a potential deadlock error in the previous release (v0.5.0).
The only change in this release is a fix to this deadlock issue. With v0.5.0, if a compile operation was using an override version of google/protobuf/descriptor.proto
, it was possible for the call to compiler.Compile
to halt, only returning if the context was cancelled or times out. This is now fixed.