-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cue: fix incorrect position in yaml import
Position information of the CUE AST is represented with bytes, whereas the YAML decoder represents position information with characters. The mismatch could result in incorrect and strange positions in the CUE AST from decoded YAML files. The simplest thing to do is to change the YAML decoder to represent position information as bytes. Other solutions may be complex or computationally expensive. I do not see the character index used in any meaningful way when decoding, so I believe this to be a safe change. In addition, it seems position information for decoded YAML documents may have been off by one, which has also been addressed. Position information for sequence end tokens were also invalid (or missing) and is now correctly set to the starting position of the sequence end event. The Kubernetes tutorial files have been updated to match the changes as a result of the corrected position information. CUE_LONG=true CUE_UPDATE=true go test ./doc/tutorial/kubernetes Fixes #826 Change-Id: Ie139708698296660b2396bc696e7b753a004a132 Signed-off-by: Thomas Way <[email protected]> Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1172017 TryBot-Result: CUEcueckoo <[email protected]> Reviewed-by: Daniel Martí <[email protected]>
- Loading branch information
Showing
11 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
exec cue import x.yaml | ||
cmp x.cue expect.cue | ||
|
||
-- x.yaml -- | ||
# Importing YAML with multi-byte characters as CUE resulted in bad formatting | ||
# since the YAML decoder would count columns by characters and we count by bytes. | ||
x1: | ||
# ああああああああああああああああああ | ||
description: ああ | ||
type: string | ||
-- expect.cue -- | ||
// Importing YAML with multi-byte characters as CUE resulted in bad formatting | ||
// since the YAML decoder would count columns by characters and we count by bytes. | ||
x1: { | ||
// ああああああああああああああああああ | ||
description: "ああ" | ||
type: "string" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters