Skip to content

Releases: bufbuild/protocompile

v0.14.1

30 Aug 17:10
4082cf0
Compare
Choose a tag to compare

What's Changed

Bugfixes changes

  • Fix bug where extension declarations marked as reserved would not allow the full_name or type fields to be specified. This failed to mirror the corresponding rule in the reference compiler protoc, 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 or options.InterpretUnlinkedOptions. By @jhump in #331

Full Changelog: v0.14.0...v0.14.1

v0.14.0

05 Jun 23:54
604d705
Compare
Choose a tag to compare

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, and google/protobuf/go_features.proto to the set of files provided by protocomile.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.
  • Add wellknownimports package, for providing actual source code for the standard imports (wellknownimports.WithStandardImports is an alternative to protocompile.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

24 Apr 13:08
9eb0fbf
Compare
Choose a tag to compare

This release includes a single addition to the protocompile.Compiler type.

What's Changed

Enhancements

  • Provide ability for caller to seed/re-use symbol table across compile jobs by @jhump in #294

Full Changelog: v0.12.0...v0.13.0

v0.12.0

22 Apr 19:55
016b009
Compare
Choose a tag to compare

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-asserting ast.Node values to ast.NoSourceNode. The change was made because of non-trivial performance gains, by greatly reducing the number of NoSourceNode values that need to be allocated on the heap when working with a parser.Result that has no AST.

Full Changelog: v0.11.0...v0.12.0

v0.11.0

17 Apr 21:52
59e75db
Compare
Choose a tag to compare

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 of google.protobuf.FeatureSet, but it is now validated for all fields set on option values.
  • 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 new Unwrap 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

08 Apr 13:49
a556a4b
Compare
Choose a tag to compare

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 and unverified_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, and sfixed64).

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.)
  • Add support for iterating option nodes in the ast sub-package via new ast.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 of ast.Node, so they also are now sub-interfaces of ast.NodeWtihOptions. The interfaces changed are ast.FileDeclNode, ast.MessageDeclNode, ast.FieldDeclNode, ast.OneofDeclNode, ast.RPCDeclNode, and ast.EnumValueDeclNode.
    • This also adds a method, ExtensionsNode, to the parser.Result interface, and expands the return types of three methods (OneofNode, EnumNode, and ServiceNode) from ast.Node to ast.NodeWithOptions.

Full Changelog: v0.9.0...v0.10.0

v0.9.0

07 Mar 17:54
8727154
Compare
Choose a tag to compare

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

22 Jan 18:36
9913977
Compare
Choose a tag to compare

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:

  1. A protocompile.Compiler would previously accept some sources that would be rejected by protoc. 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 and Visitor method) must be removed.
  2. A protocompile.Compiler would previously reject some sources that would protoc would accept. In particular, protocompile did not allow -nan as a default field value or custom option value and it also did not accept inf and alternate case spellings (such as upper- or mixed-case) of infinity and nan in message literals, which are all allowed by protoc.

v0.7.1

07 Dec 23:26
1cb5ed7
Compare
Choose a tag to compare

Fixes:

  1. If a protocompile.Compiler's Resolver returns a *descriptorpb.FileDescriptorProto (instead of source code or an already-built protoreflect.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

01 Dec 19:47
fa71488
Compare
Choose a tag to compare

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:

  1. Previously, protocompile would allow the packed 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. So protocompile now also rejects such incorrect sources.
  2. 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:

  1. The ErrorWithPos interface has two new methods, Start() ast.SourcePos and End() 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.
  2. The various helper functions for creating ErrorWithPos instances now accept an ast.SourceSpan instead of an ast.SourcePos. This includes reporter.Error and reporter.Errorf as well as the methods HandleErrorWithPos, HandleErrorf, HandleWarningWithPos, and HandleWarningf of reporter.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, or ast.Comment) is not readily available to them, they can use ast.NewSourceSpan to construct a span whose start and end are the same ast.SourcePos and pass that.

Additions:

  1. A new ast.SourceSpan interface type has been added that represents a span of code. There are also two factory functions for creating instances of ast.SourceSpan: ast.NewSourceSpan and ast.UnknownSpan. This interface is implemented by existing types ast.NodeInfo, ast.ItemInfo, ast.Comment, and reporter.ErrorWithPos.
  2. 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.