Floats with integral mantissa are mangled by printing #487
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#487
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
Commands that can print out Nix language expressions (
nix-instantiate --parse
), or things that look like such (nix-instantiate --eval
,nix eval
,nix repl
), do not show a decimal point when printing floats whose mantissa (in decimal notation) happens to be an integer. The result is misinterpreted as an integer (when there is no exponent), or as a sequence of an integer, the variablee
, a plus or minus sign, and another integer (when there is an exponent, since the parser does not accept floats without decimal point and allows termination of integer literals by random letters).Steps To Reproduce
nix-instantiate --parse --expr 1.0
prints1
nix-instantiate --parse --expr 1.0e10
prints1e+10
nix-instantiate --parse --expr 1e+10
prints:Expected behavior
Floats are printed in a way that allows Lix to parse them as floats again.
nix --version
outputnix (Lix, like Nix) 2.92.0-dev-pref2e7f8bab875
Additional context
Some cppnix bugs complaining about this behaviour:
https://github.com/NixOS/nix/issues/3077
https://github.com/NixOS/nix/issues/5063
https://github.com/NixOS/nix/issues/7554
That this happens even for
nix-instantiate --parse
is not mentioned there, but I think actually most severe, since one would expect this command to print a Nix expression equivalent to the original one. The other commands have no such guarantee (and do occasionally print out other unparseable things, such as«repeated»
or subnormals), but it's still a footgun.This issue was mentioned on Gerrit on the following CLs:
Expr::show
, add JSON expression serialization")Expr::show
, add JSON expression serialization")