Skip to content

v0.7.0

Compare
Choose a tag to compare
@jhump jhump released this 01 Dec 19:47
fa71488

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.