I think the following output makes more sense, because it matches the implicit precedence of the merge operator.
foo test {
a = 1;
} // {
b = 2;
c = 3;
}
When parentheses are added according to precedence, nixpkgs-fmt gives a result similar to the expected output above.
(foo test {
a = 1;
}) // {
b = 2;
c = 3;
}
Hence, I think the current output is confusing readers into the wrong precedence for //, and may trick them into parsing the expression incorrectly.
Now, I understand this issue is a bit tricky. In particular, when parentheses are added to perform the merge first (force higher precedence than default), nixpkgs-fmt gives a result quite similar to the one above. So parenthesizing the expression about anywhere changes the output. And I do not have a general rule to apply here yet, just this snippet.
foo test ({
a = 1;
} // {
b = 2;
c = 3;
})
PS: The online formatter with "submit code sample" is so nice to use !
Input
Output
Desired output
I think the following output makes more sense, because it matches the implicit precedence of the merge operator.
When parentheses are added according to precedence, nixpkgs-fmt gives a result similar to the expected output above.
Hence, I think the current output is confusing readers into the wrong precedence for
//
, and may trick them into parsing the expression incorrectly.Now, I understand this issue is a bit tricky. In particular, when parentheses are added to perform the merge first (force higher precedence than default), nixpkgs-fmt gives a result quite similar to the one above. So parenthesizing the expression about anywhere changes the output. And I do not have a general rule to apply here yet, just this snippet.
PS: The online formatter with "submit code sample" is so nice to use !