Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixfmt modifies integers to signed 32 bits integers on 32 bit platforms #261

Closed
symphorien opened this issue Nov 1, 2024 · 1 comment · Fixed by #262
Closed

nixfmt modifies integers to signed 32 bits integers on 32 bit platforms #261

symphorien opened this issue Nov 1, 2024 · 1 comment · Fixed by #262
Labels
bug Something isn't working correctness Output parses differently after formatting

Comments

@symphorien
Copy link
Member

Description

nixfmt formats 3000000000 into -1294967296 on armv7 (a 32 bit platform)

Steps to reproduce

$  echo '3000000000' | /nix/store/g5sxhbx8c0h585rnyacf3caa1k9pzq3n-nixfmt-unstable-2024-08-08/bin/nixfmt
-1294967296                                                                                                                                                                                                                                                                                                                                                                                         

3000000000 is a 32 bit unsigned integer with the first bit set: reinterpreted as a signed 32 bit integer it becomes -1294967296

Context:

32bit nix handles these numbers fine:

$  nix repl
Welcome to Nix 2.18.5. Type :? for help.

nix-repl> 3000000000
3000000000

nixfmt does not have this issue on x86_64 (and presumably on all 64bit platforms)

@infinisil infinisil added bug Something isn't working correctness Output parses differently after formatting labels Nov 2, 2024
@infinisil
Copy link
Member

Damn, good catch, made a PR, please try it out: #262

@github-project-automation github-project-automation bot moved this from Todo to Done in Nix formatting Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctness Output parses differently after formatting
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants