kamadorueda / alejandra

The Uncompromising Nix Code Formatter
https://kamadorueda.github.io/alejandra/
The Unlicense
827 stars 40 forks source link

Comment at the top of function body is missing indentation #383

Open DavHau opened 1 year ago

DavHau commented 1 year ago

alejandra: 3.0.0 input:

let
  loadField = field: val:
    # This commend is indented incorrectly
    if field == val
    then "foo"
    else "bar";
in
  loadField

output:

let
  loadField = field: val:
  # This commend is indented incorrectly
    if field == val
    then "foo"
    else "bar";
in
  loadField
piegamesde commented 1 year ago

Due to the way Alejandra works internally, "Comment at the top of function body is missing indentation" would be a more appropriate title. (The code responsible for this is on the outside, i.e. function application.) Additionally, it would be interesting to test if this also happens inside other language features like let blocks.