-
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.
cue: add experiment to default to int64 in Value.Decode for integers
We were defaulting to int rather than int32 or int64, so the behavior changed depending on whether the host platform was 32-bit or 64-bit. This got caught by the encoding/toml tests, which use a hexadecimal value which happens to be large enough to not fit into int32. Thus, the tests roundtripping from TOML to CUE and back to TOML would make the value overflow and become negative, causing a test failure. This issue was not covered in TestDecode as none of the test cases used large enough numbers. Add them, verifying that they showed the wrong behavior on GOARCH=386. We can soon start testing this by adding a CI step on amd64 like: GOARCH=386 go test -short ./... The TOML tests also needed tweaking. First, don't rely on JSONEquals, as that doesn't spot cases where we lose type information, and we were doing just that by re-encoding dates and times as strings. Second, the use of a large integer in one of the tests again caused the value to be re-encoded as a string on 32-bit architectures. Both of these subtest cases are skipped with a TODO for now. We don't do this change abruptly, as it could subtly break a number of downstream CUE users who may be using type switches or other reflection logic on the Go values obtained when decoding into `any`. Instead, we add a new experiment via `CUE_EXPERIMENT=decodeint64`, which will be off by default in v0.11, on by default in v0.12, and then sunset entirely in v0.13 assuming all goes well. This should give end users two full release cycles, or about six months, to adapt to the slight change in semantics underfoot. Updates #3540. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: I2b810ec972b60b4f0146ce512acaa1b585ad837f Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1203193 Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com> TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Reviewed-by: Roger Peppe <rogpeppe@gmail.com>
- Loading branch information
Showing
5 changed files
with
90 additions
and
4 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
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