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

Parse failure after formatting (123).attr or "OK" #410

Open
9999years opened this issue Mar 27, 2024 · 0 comments
Open

Parse failure after formatting (123).attr or "OK" #410

9999years opened this issue Mar 27, 2024 · 0 comments

Comments

@9999years
Copy link
Contributor

We can evaluate this expression:

nix-repl> (123).attr or "OK"
"OK"

Alejandra removes the 'redundant' parenthesis around 123:

-(123).attr or "OK"
+123.attr or "OK"

And then it fails to parse:

$ alejandra number-parens-attr.nix
Failed! 1 error found at:
- number-parens-attr.nix: error node at 0..4

This is because (123).attr parses as "the attr attribute of 123" and 123.attr parses as "the value of the attr variable applied to the function 123.":

$ nix-instantiate --parse --expr 'let attr = 1; in 123.attr'
(let attr = 1; in (123 attr))
$ nix-instantiate --parse --expr 'let attr = 1; in (123).attr'
(let attr = 1; in (123).attr)

Version information:

$ alejandra --version
Alejandra 3.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant