tvix: warn when floats are converted to string (or json or toml)
#367
Opened by flokli at
Rendering floats to strings (decimal representation) is a bit fuzzy.
Some floats are be periodic (in their decimal or binary representation), and there is a loss of precision. There might also be some corner cases with math, where different architectures might produce different results.
This is very terrible in places where we rely on reproducible output, such as hashing functions.
- rendering floats into build artifacts can break binary reproducibility (and/or break FODs)
- using floats in structured attrs (which gets serialized to json in ATerm affects store path hashes
More context:
- toJSON truncates floats
- nix repl: float printing not compatible with parsing (1e10)
- Some floats are printed like ints
- nixos/manual: lengthScale default value formatting depends on nix version
We should discourage float usage in Tvix.
There should be a way (feature flag/runtime config) to entirely disallow it. In case it is used, we should probably warn where it's used.
- flokli updated the body of this issue at 2024-01-12T10·35+00