Add a Positioned type to fix RawValue error position.
#933
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
RawValuecan be used to defer parsing until later, but errors reported during the second parsing step will report line and column numbers relative to the start of theRawValue, not to the start of the actual input. This is unhelpful and confusing to users unaware of the inner workings of the deserialization process.This pull request add a
Positionedtype that can be wrapped around any other deserializable type to save the position in the input stream, and aPositionedReadtype to allow deserializing fromPositionedwhile fixing reported line and column numbers.This can be used as follows (with the
raw_valuefeature enabled):Without
Positionedthis would report an incorrect position for the error during the two-step deserialization:With the
Positionedinner deserialization step, this correctly reports the error position: