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,
protocompilewould allow thepackedfield 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. Soprotocompilenow 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
ErrorWithPosinterface has two new methods,Start() ast.SourcePosandEnd() 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
ErrorWithPosinstances now accept anast.SourceSpaninstead of anast.SourcePos. This includesreporter.Errorandreporter.Errorfas well as the methodsHandleErrorWithPos,HandleErrorf,HandleWarningWithPos, andHandleWarningfofreporter.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.NewSourceSpanto construct a span whose start and end are the sameast.SourcePosand 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.SourceSpaninterface type has been added that represents a span of code. There are also two factory functions for creating instances ofast.SourceSpan:ast.NewSourceSpanandast.UnknownSpan. This interface is implemented by existing typesast.NodeInfo,ast.ItemInfo,ast.Comment, andreporter.ErrorWithPos. - A new
github.com/bufbuild/protocompile/parser/fastscanpackage 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.