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
Labels
component | engine Core algorithm of the tool good first issue Good for newcomers help wanted Extra attention is needed status | it is a good thing We agree it is good to implement this type | bug Something isn't working

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
@kamadorueda kamadorueda added type | bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers status | it is a good thing We agree it is good to implement this component | engine Core algorithm of the tool labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component | engine Core algorithm of the tool good first issue Good for newcomers help wanted Extra attention is needed status | it is a good thing We agree it is good to implement this type | bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants