fix: TomlRenderer large integers render as decimal not scientific notation#956
Merged
stephenamar-db merged 2 commits intoJun 18, 2026
Conversation
79c4fc0 to
edb04d7
Compare
…ific notation Motivation: Large integer values like 1e20 were rendered as "1.0E20" (scientific notation) in TOML output, which is invalid TOML integer format. go-jsonnet renders these as "100000000000000000000". Modification: - Add BigDecimal fallback in visitFloat64 for integers that exceed Long range (where math.round(d).toDouble != d but d % 1 == 0) - Uses BigDecimal.setScale(0).toBigInt to produce exact decimal string - Add directional tests verifying large integers, regular integers, and fractional values render correctly Result: std.manifestToml now renders large integer values as proper decimal strings instead of scientific notation, matching go-jsonnet behavior. References: docs/semantic-bugs-v2.md Bug 17
edb04d7 to
97fa49e
Compare
Motivation:
std.contains only accepts arrays, not strings. The test file used
std.contains with string arguments, causing all CI platforms to fail
with "[std.contains] Wrong parameter type: expected Array, got string".
Modification:
Replace std.contains(large, "E") with
std.length(std.findSubstr("E", large)) == 0 for string substring checks.
Result:
toml_renderer_large_integer.jsonnet test now passes on all platforms.
stephenamar-db
approved these changes
Jun 18, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
TomlRenderer.visitFloat64rendered large integers like1e20as"1.0E20"(scientific notation), which is invalid TOML integer format. go-jsonnet renders1e20as100000000000000000000. TheRendererandBaseCharRendererhadBigDecimalfallback logic, butTomlRendererwas missing it.Modification
BigDecimalfallback between the Long-range check andDouble.toString: whenmath.round(d).toDouble != dbutd % 1 == 0, usesBigDecimal.toBigIntfor exact decimal outputResult
std.manifestToml({a: 1e20})now rendersa = 100000000000000000000instead ofa = 1.0E20, matching go-jsonnet and producing valid TOML output.References
std.manifestToml({a: 1e20})a = 100000000000000000000a = 100000000000000000000a = 1.0E20❌a = 100000000000000000000✅std.manifestToml({a: 42})a = 42a = 42a = 42✅a = 42✅std.manifestToml({a: 3.14})a = 3.14a = 3.14a = 3.14✅a = 3.14✅