Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
encoding/json: fix positions when Decoder.Extract finds bad syntax
In such a scenario, such as when decoding JSONL files as a stream of newline-delimited JSON values, we would simply use encoding/json's Decoder.InputOffset, which is the end of the last returned token. Or in our case, the end of the last fully decoded RawMessage, which is the previous value in the JSONL rather than the current one. Copy the new mechanism that Extract gained to deal with json.SyntaxError into Decoder.Extract, with some tweaks as we can reuse our token.File. While here, simplify the code a bit; there is no need to use errors.As, as the encoding/json docs guarantee that SyntaxError is not wrapped. Fixes #2776. Signed-off-by: Daniel Martí <[email protected]> Change-Id: I41d6661d3a4ba59d72ab061f261356700f45aeda Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1199103 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Roger Peppe <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
- Loading branch information